You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like it would be possible to build a wrapper for something like std::thread::spawn that, under the hood, sends the closure to another worker (possibly by boxing and maybe needs to turn it into a raw pointer)
pubfnspawn_thread<T,F>(f:F) -> JoinHandle<T>whereF:FnOnce() -> T + Send +'static,T:Send + 'static{// (std/crossbeam should work, maybe one_shot works too?)let(send, recv) = std::sync::mpsc::channel();let(out_send, out_recv) = std::sync::mpsc::channel();// create a worker with js_sys that:// - init the wasm module (produced by wasm-bindgen) inside the worker with the same (shared) WebAssembly.Memory// - recv and execute the closure// - send the result back// send the closure to the worker
send.send(f).unwrap()JoinHandle{recv: out_recv }}
(if this won't work please educate me why)
The text was updated successfully, but these errors were encountered:
threads proposal has reached phase 4 - https://webassembly.org/features/
Seems like it would be possible to build a wrapper for something like
std::thread::spawn
that, under the hood, sends the closure to another worker (possibly by boxing and maybe needs to turn it into a raw pointer)(if this won't work please educate me why)
The text was updated successfully, but these errors were encountered: