| ... | @@ -1134,24 +1134,14 @@ pub fn Future(Result: type) type { | ... | @@ -1134,24 +1134,14 @@ pub fn Future(Result: type) type { |
| 1134 | /// Idempotent. | 1134 | /// Idempotent. |
| 1135 | pub fn cancel(f: *@This(), io: Io) Result { | 1135 | pub fn cancel(f: *@This(), io: Io) Result { |
| 1136 | const any_future = f.any_future orelse return f.result; | 1136 | const any_future = f.any_future orelse return f.result; |
| 1137 | io.vtable.cancel( | 1137 | io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result)); |
| 1138 | io.userdata, | | |
| 1139 | any_future, | | |
| 1140 | if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug | | |
| 1141 | .of(Result), | | |
| 1142 | ); | | |
| 1143 | f.any_future = null; | 1138 | f.any_future = null; |
| 1144 | return f.result; | 1139 | return f.result; |
| 1145 | } | 1140 | } |
| 1146 | | 1141 | |
| 1147 | pub fn await(f: *@This(), io: Io) Result { | 1142 | pub fn await(f: *@This(), io: Io) Result { |
| 1148 | const any_future = f.any_future orelse return f.result; | 1143 | const any_future = f.any_future orelse return f.result; |
| 1149 | io.vtable.await( | 1144 | io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result)); |
| 1150 | io.userdata, | | |
| 1151 | any_future, | | |
| 1152 | if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug | | |
| 1153 | .of(Result), | | |
| 1154 | ); | | |
| 1155 | f.any_future = null; | 1145 | f.any_future = null; |
| 1156 | return f.result; | 1146 | return f.result; |
| 1157 | } | 1147 | } |
| ... | @@ -1515,9 +1505,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio | ... | @@ -1515,9 +1505,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio |
| 1515 | var future: Future(Result) = undefined; | 1505 | var future: Future(Result) = undefined; |
| 1516 | future.any_future = io.vtable.async( | 1506 | future.any_future = io.vtable.async( |
| 1517 | io.userdata, | 1507 | io.userdata, |
| 1518 | if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug | 1508 | @ptrCast((&future.result)[0..1]), |
| 1519 | .of(Result), | 1509 | .of(Result), |
| 1520 | if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug | 1510 | @ptrCast((&args)[0..1]), |
| 1521 | .of(Args), | 1511 | .of(Args), |
| 1522 | TypeErased.start, | 1512 | TypeErased.start, |
| 1523 | ); | 1513 | ); |
| ... | @@ -1534,12 +1524,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function)) | ... | @@ -1534,12 +1524,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function)) |
| 1534 | @call(.auto, function, args_casted.*); | 1524 | @call(.auto, function, args_casted.*); |
| 1535 | } | 1525 | } |
| 1536 | }; | 1526 | }; |
| 1537 | io.vtable.go( | 1527 | io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start); |
| 1538 | io.userdata, | | |
| 1539 | if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug | | |
| 1540 | .of(Args), | | |
| 1541 | TypeErased.start, | | |
| 1542 | ); | | |
| 1543 | } | 1528 | } |
| 1544 | | 1529 | |
| 1545 | pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp { | 1530 | pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp { |