| ... | ... | @@ -202,8 +202,8 @@ inline fn initEventLoopAndCallMain() u8 { |
| 202 | 202 | defer loop.deinit(); |
| 203 | 203 | |
| 204 | 204 | var result: u8 = undefined; |
| 205 | | var frame: @Frame(callMain) = undefined; |
| 206 | | _ = @asyncCall(&frame, &result, callMain); |
| 205 | var frame: @Frame(callMainAsync) = undefined; |
| 206 | _ = @asyncCall(&frame, &result, callMainAsync, loop); |
| 207 | 207 | loop.run(); |
| 208 | 208 | return result; |
| 209 | 209 | } |
| ... | ... | @@ -214,6 +214,13 @@ inline fn initEventLoopAndCallMain() u8 { |
| 214 | 214 | return @inlineCall(callMain); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | fn callMainAsync(loop: *std.event.Loop) u8 { |
| 218 | // This prevents the event loop from terminating at least until main() has returned. |
| 219 | loop.beginOneEvent(); |
| 220 | defer loop.finishOneEvent(); |
| 221 | return callMain(); |
| 222 | } |
| 223 | |
| 217 | 224 | // This is not marked inline because it is called with @asyncCall when |
| 218 | 225 | // there is an event loop. |
| 219 | 226 | fn callMain() u8 { |