| ... | ... | @@ -781,24 +781,14 @@ pub fn Future(Result: type) type { |
| 781 | 781 | /// Idempotent. |
| 782 | 782 | pub fn cancel(f: *@This(), io: Io) Result { |
| 783 | 783 | const any_future = f.any_future orelse return f.result; |
| 784 | | io.vtable.cancel( |
| 785 | | io.userdata, |
| 786 | | any_future, |
| 787 | | if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug |
| 788 | | .of(Result), |
| 789 | | ); |
| 784 | io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result)); |
| 790 | 785 | f.any_future = null; |
| 791 | 786 | return f.result; |
| 792 | 787 | } |
| 793 | 788 | |
| 794 | 789 | pub fn await(f: *@This(), io: Io) Result { |
| 795 | 790 | const any_future = f.any_future orelse return f.result; |
| 796 | | io.vtable.await( |
| 797 | | io.userdata, |
| 798 | | any_future, |
| 799 | | if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug |
| 800 | | .of(Result), |
| 801 | | ); |
| 791 | io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result)); |
| 802 | 792 | f.any_future = null; |
| 803 | 793 | return f.result; |
| 804 | 794 | } |
| ... | ... | @@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio |
| 1162 | 1152 | var future: Future(Result) = undefined; |
| 1163 | 1153 | future.any_future = io.vtable.async( |
| 1164 | 1154 | io.userdata, |
| 1165 | | if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug |
| 1155 | @ptrCast((&future.result)[0..1]), |
| 1166 | 1156 | .of(Result), |
| 1167 | | if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug |
| 1157 | @ptrCast((&args)[0..1]), |
| 1168 | 1158 | .of(Args), |
| 1169 | 1159 | TypeErased.start, |
| 1170 | 1160 | ); |
| ... | ... | @@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function)) |
| 1181 | 1171 | @call(.auto, function, args_casted.*); |
| 1182 | 1172 | } |
| 1183 | 1173 | }; |
| 1184 | | io.vtable.go( |
| 1185 | | io.userdata, |
| 1186 | | if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug |
| 1187 | | .of(Args), |
| 1188 | | TypeErased.start, |
| 1189 | | ); |
| 1174 | io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start); |
| 1190 | 1175 | } |
| 1191 | 1176 | |
| 1192 | 1177 | pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp { |