authorgravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-08-02 17:52:40+09:00
committergravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-08-02 17:52:40+09:00
log96a94e7da933dafec25356c435f5725c3cb0ce04
tree5227e8bb2321f27bfd908cd8a601b3360aca19bb
parentac0a87d58d72a8c1fbb9b0af2d3818075729d85a

std/event: directly return @handle();

Tracking Issue #1296 ;

4 files changed, 6 insertions(+), 12 deletions(-)

std/event/future.zig+3-6
...@@ -101,8 +101,7 @@ test "std.event.Future" {...@@ -101,8 +101,7 @@ test "std.event.Future" {
101101
102async fn testFuture(loop: *Loop) void {102async fn testFuture(loop: *Loop) void {
103 suspend {103 suspend {
104 var h: promise = @handle();104 resume @handle();
105 resume h;
106 }105 }
107 var future = Future(i32).init(loop);106 var future = Future(i32).init(loop);
108107
...@@ -117,16 +116,14 @@ async fn testFuture(loop: *Loop) void {...@@ -117,16 +116,14 @@ async fn testFuture(loop: *Loop) void {
117116
118async fn waitOnFuture(future: *Future(i32)) i32 {117async fn waitOnFuture(future: *Future(i32)) i32 {
119 suspend {118 suspend {
120 var h: promise = @handle();119 resume @handle();
121 resume h;
122 }120 }
123 return (await (async future.get() catch @panic("memory"))).*;121 return (await (async future.get() catch @panic("memory"))).*;
124}122}
125123
126async fn resolveFuture(future: *Future(i32)) void {124async fn resolveFuture(future: *Future(i32)) void {
127 suspend {125 suspend {
128 var h: promise = @handle();126 resume @handle();
129 resume h;
130 }127 }
131 future.data = 6;128 future.data = 6;
132 future.resolve();129 future.resolve();
std/event/group.zig+1-2
...@@ -57,8 +57,7 @@ pub fn Group(comptime ReturnType: type) type {...@@ -57,8 +57,7 @@ pub fn Group(comptime ReturnType: type) type {
57 suspend {57 suspend {
58 var my_node: Stack.Node = undefined;58 var my_node: Stack.Node = undefined;
59 node.* = &my_node;59 node.* = &my_node;
60 var h: promise = @handle();60 resume @handle();
61 resume h;
62 }61 }
6362
64 // TODO this allocation elision should be guaranteed because we await it in63 // TODO this allocation elision should be guaranteed because we await it in
std/event/lock.zig+1-2
...@@ -142,8 +142,7 @@ test "std.event.Lock" {...@@ -142,8 +142,7 @@ test "std.event.Lock" {
142async fn testLock(loop: *Loop, lock: *Lock) void {142async fn testLock(loop: *Loop, lock: *Lock) void {
143 // TODO explicitly put next tick node memory in the coroutine frame #1194143 // TODO explicitly put next tick node memory in the coroutine frame #1194
144 suspend {144 suspend {
145 var h: promise = @handle();145 resume @handle();
146 resume h;
147 }146 }
148 const handle1 = async lockRunner(lock) catch @panic("out of memory");147 const handle1 = async lockRunner(lock) catch @panic("out of memory");
149 var tick_node1 = Loop.NextTickNode{148 var tick_node1 = Loop.NextTickNode{
std/event/tcp.zig+1-2
...@@ -142,8 +142,7 @@ test "listen on a port, send bytes, receive bytes" {...@@ -142,8 +142,7 @@ test "listen on a port, send bytes, receive bytes" {
142 std.debug.panic("unable to handle connection: {}\n", err);142 std.debug.panic("unable to handle connection: {}\n", err);
143 };143 };
144 suspend {144 suspend {
145 var h: promise = @handle();145 cancel @handle();
146 cancel h;
147 }146 }
148 }147 }
149 async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void {148 async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void {