Additional usage: WASM async in non-async functions
amyipdev opened this issue · 2 comments
amyipdev commented
Especially when passing around functions, trying to use async in wasm (particularly without WASI) is currently an absolute mess. I've been stuck for weeks on one particular issue in a project, and finally came across this, and it worked. Perhaps it should be mentioned as a usage in the README?
amyipdev commented
Nevermind, this doesn't work in WASM either...
zesterer commented
Async in WASM uses a single-thread co-operative model, where each task must regularly yield to allow other tasks to progress. By design (this isn't a bug, it's just a consequence of the block_on
API), pollster
will halt the current thread until the future has finished, but this is entirely incompatible with WASM since it prevents anything making forward progress.