authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-11 20:17:47-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-11 20:17:47-04:00
log30c4add85a0f4af727ad7cf8f2134114329d0f07
tree4ba5d502074df031b3bc55f0f5a347294888d81c
parent9751a0ae045110fb615c866b94ad47680b9c48c7

std.event.Future: workaround in tests for llvm coro memory

See #1194

2 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;
4pub const tcp = @import("event/tcp.zig");4pub const tcp = @import("event/tcp.zig");
5pub const Channel = @import("event/channel.zig").Channel;5pub const Channel = @import("event/channel.zig").Channel;
6pub const Group = @import("event/group.zig").Group;6pub const Group = @import("event/group.zig").Group;
7pub const Future = @import("event/future.zig").Group;7pub const Future = @import("event/future.zig").Future;
88
9test "import event tests" {9test "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}
6868
69async fn testFuture(loop: *Loop) void {69async 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);
7174
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}
8083
81async fn waitOnFuture(future: *Future(i32)) i32 {84async 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}
8490
85async fn resolveFuture(future: *Future(i32)) void {91async 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}