Skip to main content

wasm_bindgen_spawn/
lib.rs

1//! ![Version Badge](https://img.shields.io/crates/v/wasm-bindgen-spawn)
2//! ![License Badge](https://img.shields.io/github/license/Pistonite/wasm-bindgen-spawn)
3//! ![Issue Badge](https://img.shields.io/github/issues/Pistonite/wasm-bindgen-spawn)
4//!
5//! A Worker based multithreading library for Rust and WebAssembly.
6//!
7//! This uses the WebAssembly [threads proposal](https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md)
8//! and shared memory to communicate between workers (once they are started), instead of `postMessage`.
9//! The threads proposal is currently in [phase 4](https://webassembly.org/features/) and available in all major browsers and runtimes.
10//!
11//! 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.
12//!
13//! To get started using this library, please refer to the [book](https://wbgspawn.pistonite.dev).
14//! The [Playground](https://wbgspawn-playground.pistonite.dev) also has runnable examples.
15
16#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics"), not(doc)))]
17compile_error!(
18    "-Ctarget_feature=atomics is not enabled. Please read the README and set the right rustflags"
19);
20
21mod spawn;
22pub use spawn::{
23    SpawnError, ThreadDispatcherInit, init_bg_no_modules, init_bg_web, spawn, spawn_async,
24    terminate_dispatcher, try_spawn, try_spawn_async,
25};
26mod join;
27pub use join::{AsyncJoinHandle, JoinHandle};
28/// The worker thread's runtime, which contains wrappers for handling panics
29mod runtime;
30pub use runtime::spawn_local;
31
32/// Interop with JS
33mod binding;
34#[allow(unused)]
35mod binding_constants;
36
37mod util;