std/event: directly return @handle();

Tracking Issue #1296 ;
This commit is contained in:
kristopher tate 2018-08-02 17:52:40 +09:00
parent ac0a87d58d
commit 96a94e7da9
4 changed files with 6 additions and 12 deletions

View File

@ -101,8 +101,7 @@ test "std.event.Future" {
async fn testFuture(loop: *Loop) void { async fn testFuture(loop: *Loop) void {
suspend { suspend {
var h: promise = @handle(); resume @handle();
resume h;
} }
var future = Future(i32).init(loop); var future = Future(i32).init(loop);
@ -117,16 +116,14 @@ async fn testFuture(loop: *Loop) void {
async fn waitOnFuture(future: *Future(i32)) i32 { async fn waitOnFuture(future: *Future(i32)) i32 {
suspend { suspend {
var h: promise = @handle(); resume @handle();
resume h;
} }
return (await (async future.get() catch @panic("memory"))).*; return (await (async future.get() catch @panic("memory"))).*;
} }
async fn resolveFuture(future: *Future(i32)) void { async fn resolveFuture(future: *Future(i32)) void {
suspend { suspend {
var h: promise = @handle(); resume @handle();
resume h;
} }
future.data = 6; future.data = 6;
future.resolve(); future.resolve();

View File

@ -57,8 +57,7 @@ pub fn Group(comptime ReturnType: type) type {
suspend { suspend {
var my_node: Stack.Node = undefined; var my_node: Stack.Node = undefined;
node.* = &my_node; node.* = &my_node;
var h: promise = @handle(); resume @handle();
resume h;
} }
// TODO this allocation elision should be guaranteed because we await it in // TODO this allocation elision should be guaranteed because we await it in

View File

@ -142,8 +142,7 @@ test "std.event.Lock" {
async fn testLock(loop: *Loop, lock: *Lock) void { async fn testLock(loop: *Loop, lock: *Lock) void {
// TODO explicitly put next tick node memory in the coroutine frame #1194 // TODO explicitly put next tick node memory in the coroutine frame #1194
suspend { suspend {
var h: promise = @handle(); resume @handle();
resume h;
} }
const handle1 = async lockRunner(lock) catch @panic("out of memory"); const handle1 = async lockRunner(lock) catch @panic("out of memory");
var tick_node1 = Loop.NextTickNode{ var tick_node1 = Loop.NextTickNode{

View File

@ -142,8 +142,7 @@ test "listen on a port, send bytes, receive bytes" {
std.debug.panic("unable to handle connection: {}\n", err); std.debug.panic("unable to handle connection: {}\n", err);
}; };
suspend { suspend {
var h: promise = @handle(); cancel @handle();
cancel h;
} }
} }
async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void { async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void {