Skip to main content

Crate wasm_bindgen_spawn

Crate wasm_bindgen_spawn 

Source
Expand description

Version Badge License Badge Issue Badge

A Worker based multithreading library for Rust and WebAssembly.

This uses the WebAssembly threads proposal and shared memory to communicate between workers (once they are started), instead of postMessage. The threads proposal is currently in phase 4 and available in all major browsers and runtimes.

This library will remain on version 0.0.x until all features required are in stable Rust, standardized in WASM, and baseline widely available across browsers.

To get started using this library, please refer to the book. The Playground also has runnable examples.

Structs§

AsyncJoinHandle
IntoFuture implementation for JoinHandle
JoinHandle
Handle for joining a thread
ThreadDispatcherInit
Thread dispatcher initialization.

Enums§

SpawnError
Thread creation error returned by try_spawn or try_spawn_async

Functions§

init_bg_no_modules
Start building a thread dispatcher using the bindgen script from the “no-modules” target. See ThreadDispatcherInit
init_bg_web
Start building a thread dispatcher using the bindgen script from the “web” target. See ThreadDispatcherInit
spawn
Spawn a new thread similar to std::thread::spawn
spawn_async
Spawn a new thread that runs co-operatively with the JS event loop.
spawn_local
Schedule a task in the JS Event Loop to drive the Rust future.
terminate_dispatcher
Terminate the thread dispatcher worker
try_spawn
Same as spawn but captures thread creation failure.
try_spawn_async
Same as spawn_async but captures thread creation failure.