Skip to content

Commit

Permalink
std.event.Future: workaround in tests for llvm coro memory
Browse files Browse the repository at this point in the history
See #1194
  • Loading branch information
andrewrk committed Jul 12, 2018
1 parent 9751a0a commit 30c4add
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion std/event.zig
Expand Up @@ -4,7 +4,7 @@ pub const Lock = @import("event/lock.zig").Lock;
pub const tcp = @import("event/tcp.zig");
pub const Channel = @import("event/channel.zig").Channel;
pub const Group = @import("event/group.zig").Group;
pub const Future = @import("event/future.zig").Group;
pub const Future = @import("event/future.zig").Future;

test "import event tests" {
_ = @import("event/locked.zig");
Expand Down
9 changes: 9 additions & 0 deletions std/event/future.zig
Expand Up @@ -67,6 +67,9 @@ test "std.event.Future" {
}

async fn testFuture(loop: *Loop) void {
suspend |p| {
resume p;
}
var future = Future(i32).init(loop);

const a = async waitOnFuture(&future) catch @panic("memory");
Expand All @@ -79,10 +82,16 @@ async fn testFuture(loop: *Loop) void {
}

async fn waitOnFuture(future: *Future(i32)) i32 {
suspend |p| {
resume p;
}
return (await (async future.get() catch @panic("memory"))).*;
}

async fn resolveFuture(future: *Future(i32)) void {
suspend |p| {
resume p;
}
future.data = 6;
future.resolve();
}

0 comments on commit 30c4add

Please sign in to comment.