Closed the-drunk-coder closed 2 years ago
You get such errors when trying to do any blocking operation that uses atomics on the main thread (README). I'm not sure if join()
was working before, but if it did then it seems that futures::executor::block_on
got smarter and it attempts to park the thread instead of busy polling, or thread::park()
was implemented for wasm in newer rust versions.
In any case, if you want to block on the main thread, you should make your scheduler entry point async fn
and use join_async().await
. It is possible to hack around and manually poll future returned by join_async()
, but browsers really don't like busy waiting and things like DOM, network, worker spawning, etc. usually freeze until non-async function terminates.
Alternatively, you could start your scheduler in a web worker, which does allow atomic wait and join()
would work fine there. This limitation only applies to the main browser thread.
Ah right, yes ... sorry, must have missed that. Thanks for the quick reply !
Hi, I tried to build a little scheduler using wasm_thread, based on the simple example (build with the provided build.sh script)
When I call
join()
on the JoinHandle, I get the following error in the console:Best, N