c++ co_await #70771
-
@lewing I noticed the "tail" instruction has been implemented in wasm for blazor webassembly? i'm wondering if the same thing could be done for c++ on webassembly to support co_await? i'm a bit out of my depth on this one, but just know that @GorNishanov said tail calls are required for co_await. tail calls look to be "in process" for webassembly spec, so wondering if someone has figured out a workaround in the meantime? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
There is a workaround for systems without tailcalls. Resume operation on the coroutine handle would become a loop. Here is a sketch of how such workaround might look like void resume(coro)
{
do {
coro = coro.real_resume_and_return_the_coro_to_transfer_or_nullptr();
} while(coro);
} |
Beta Was this translation helpful? Give feedback.
There is a workaround for systems without tailcalls. Resume operation on the coroutine handle would become a loop.
Tail calls is used in situations when a coroutine performs symmetrical transfer, ie. coroutine 1 suspends and then resumes coroutine 2.
Here is a sketch of how such workaround might look like