| author | |
| committer | |
| log | 30c4add85a0f4af727ad7cf8f2134114329d0f07 |
| tree | 4ba5d502074df031b3bc55f0f5a347294888d81c |
| parent | 9751a0ae045110fb615c866b94ad47680b9c48c7 |
See #11942 files changed, 10 insertions(+), 1 deletions(-)
std/event.zig+1-1| ... | @@ -4,7 +4,7 @@ pub const Lock = @import("event/lock.zig").Lock; | ... | @@ -4,7 +4,7 @@ pub const Lock = @import("event/lock.zig").Lock; |
| 4 | pub const tcp = @import("event/tcp.zig"); | 4 | pub const tcp = @import("event/tcp.zig"); |
| 5 | pub const Channel = @import("event/channel.zig").Channel; | 5 | pub const Channel = @import("event/channel.zig").Channel; |
| 6 | pub const Group = @import("event/group.zig").Group; | 6 | pub const Group = @import("event/group.zig").Group; |
| 7 | pub const Future = @import("event/future.zig").Group; | 7 | pub const Future = @import("event/future.zig").Future; |
| 8 | 8 | ||
| 9 | test "import event tests" { | 9 | test "import event tests" { |
| 10 | _ = @import("event/locked.zig"); | 10 | _ = @import("event/locked.zig"); |
std/event/future.zig+9| ... | @@ -67,6 +67,9 @@ test "std.event.Future" { | ... | @@ -67,6 +67,9 @@ test "std.event.Future" { |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | async fn testFuture(loop: *Loop) void { | 69 | async fn testFuture(loop: *Loop) void { |
| 70 | suspend |p| { | ||
| 71 | resume p; | ||
| 72 | } | ||
| 70 | var future = Future(i32).init(loop); | 73 | var future = Future(i32).init(loop); |
| 71 | 74 | ||
| 72 | const a = async waitOnFuture(&future) catch @panic("memory"); | 75 | const a = async waitOnFuture(&future) catch @panic("memory"); |
| ... | @@ -79,10 +82,16 @@ async fn testFuture(loop: *Loop) void { | ... | @@ -79,10 +82,16 @@ async fn testFuture(loop: *Loop) void { |
| 79 | } | 82 | } |
| 80 | 83 | ||
| 81 | async fn waitOnFuture(future: *Future(i32)) i32 { | 84 | async fn waitOnFuture(future: *Future(i32)) i32 { |
| 85 | suspend |p| { | ||
| 86 | resume p; | ||
| 87 | } | ||
| 82 | return (await (async future.get() catch @panic("memory"))).*; | 88 | return (await (async future.get() catch @panic("memory"))).*; |
| 83 | } | 89 | } |
| 84 | 90 | ||
| 85 | async fn resolveFuture(future: *Future(i32)) void { | 91 | async fn resolveFuture(future: *Future(i32)) void { |
| 92 | suspend |p| { | ||
| 93 | resume p; | ||
| 94 | } | ||
| 86 | future.data = 6; | 95 | future.data = 6; |
| 87 | future.resolve(); | 96 | future.resolve(); |
| 88 | } | 97 | } |