wasm-mt-pool
A thread pool library based on wasm-mt
(github | crate).
Examples
You can run all the following apps in browser!
- pool_exec - How to use wasm_mt_pool. [ live | source ]
- http - A multithreaded server based on wasm_mt_pool. [ live | source ]
- pool_arraybuffers - Demo of using ThreadPool::new_with_arraybuffers(). [ live | source ]
Getting started
Requirements:
- rustc (nightly)
wasm-pack build
with the--target no-modules
option
Cargo.toml:
= "0.1"
= { = "1.0", = ["derive"] }
= "0.2"
Usage
use *;
use ;
let size = 2;
let pkg_js = "./pkg/pool_exec.js"; // path to `wasm-bindgen`'s JS binding
let pool = new.and_init.await.unwrap;
let num = 4;
console_ln!;
for _ in 0..num
console_ln!;
for _ in 0..num
let cb = move |result| ;
console_ln!;
for _ in 0..num
console_ln!;
for _ in 0..num
sleep.await; // Do sleep long enough to ensure all jobs are completed.
assert_eq!;