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