mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 22:04:21 +00:00
parent
0c1e102e97
commit
61c38d77c6
1 changed files with 5 additions and 20 deletions
|
|
@ -781,24 +781,14 @@ pub fn Future(Result: type) type {
|
||||||
/// Idempotent.
|
/// Idempotent.
|
||||||
pub fn cancel(f: *@This(), io: Io) Result {
|
pub fn cancel(f: *@This(), io: Io) Result {
|
||||||
const any_future = f.any_future orelse return f.result;
|
const any_future = f.any_future orelse return f.result;
|
||||||
io.vtable.cancel(
|
io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
|
||||||
io.userdata,
|
|
||||||
any_future,
|
|
||||||
if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
|
|
||||||
.of(Result),
|
|
||||||
);
|
|
||||||
f.any_future = null;
|
f.any_future = null;
|
||||||
return f.result;
|
return f.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn await(f: *@This(), io: Io) Result {
|
pub fn await(f: *@This(), io: Io) Result {
|
||||||
const any_future = f.any_future orelse return f.result;
|
const any_future = f.any_future orelse return f.result;
|
||||||
io.vtable.await(
|
io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
|
||||||
io.userdata,
|
|
||||||
any_future,
|
|
||||||
if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
|
|
||||||
.of(Result),
|
|
||||||
);
|
|
||||||
f.any_future = null;
|
f.any_future = null;
|
||||||
return f.result;
|
return f.result;
|
||||||
}
|
}
|
||||||
|
|
@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio
|
||||||
var future: Future(Result) = undefined;
|
var future: Future(Result) = undefined;
|
||||||
future.any_future = io.vtable.async(
|
future.any_future = io.vtable.async(
|
||||||
io.userdata,
|
io.userdata,
|
||||||
if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug
|
@ptrCast((&future.result)[0..1]),
|
||||||
.of(Result),
|
.of(Result),
|
||||||
if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
|
@ptrCast((&args)[0..1]),
|
||||||
.of(Args),
|
.of(Args),
|
||||||
TypeErased.start,
|
TypeErased.start,
|
||||||
);
|
);
|
||||||
|
|
@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))
|
||||||
@call(.auto, function, args_casted.*);
|
@call(.auto, function, args_casted.*);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
io.vtable.go(
|
io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start);
|
||||||
io.userdata,
|
|
||||||
if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
|
|
||||||
.of(Args),
|
|
||||||
TypeErased.start,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {
|
pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue