bool called = false; async void noop() { } async void foo_async() { if (called) { stdout.puts("foo_async(): wait\n"); while (called) yield noop(); return; } stdout.puts("foo_async(): execute\n"); called = true; for (var i = 0; i < 100000; ++i); yield noop(); called = false; } int main() { foo_async.begin((obj, res) => { foo_async.end(res); stdout.puts("1'st foo_async() ended\n"); }); foo_async.begin((obj, res) => { foo_async.end(res); stdout.puts("2'nd foo_async() ended\n"); }); var loop = new MainLoop(); var t = new TimeoutSource(0); t.set_callback(() => { loop.quit(); return false; }); t.attach(loop.get_context()); loop.run(); return 0; }