Skip to content

Commit a7f1a4c

Browse files
committed
Release version 0.3.0
1 parent 2c7ef20 commit a7f1a4c

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ readme = "README.md"
1111
keywords = ["webworker", "parallelism", "wasm"]
1212

1313
[workspace.dependencies]
14-
wasmworker = { version = "0.2", path = ".", features = ["serde", "macros"] }
15-
wasmworker-proc-macro = { version = "0.2", path = "proc-macro" }
14+
wasmworker = { version = "0.3", path = ".", features = ["serde", "macros"] }
15+
wasmworker-proc-macro = { version = "0.3", path = "proc-macro" }
1616

1717
[package]
1818
name = "wasmworker"
19-
version = "0.2.1"
19+
version = "0.3.0"
2020
edition = "2021"
2121

2222
description.workspace = true

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ In contrast to many other libraries like [wasm-bindgen-rayon](https://github.com
1010
- [Iterator extension](#iterator-extension)
1111
- [Async functions with channels](#async-functions-with-channels)
1212
- [Bundler support (Vite)](#bundler-support-vite)
13+
- [Idle timeout](#idle-timeout)
1314
- [FAQ](#faq)
1415

1516
## Usage
@@ -20,7 +21,7 @@ Enable the `macros` feature to get access to the `#[webworker_fn]` and `#[webwor
2021

2122
```toml
2223
[dependencies]
23-
wasmworker = { version = "0.2", features = ["macros"] }
24+
wasmworker = { version = "0.3", features = ["macros"] }
2425
```
2526

2627
The `wasmworker` crate comes with a default feature called `serde`, which allows running any function on a web worker under the following two conditions:
@@ -252,6 +253,20 @@ options.precompile_wasm = Some(true);
252253
init_worker_pool(options).await.unwrap();
253254
```
254255

256+
### Idle timeout
257+
258+
Workers can be automatically terminated after a period of inactivity and transparently recreated when new tasks arrive. This is useful for freeing resources in applications where worker usage is intermittent:
259+
260+
```rust
261+
use wasmworker::{init_worker_pool, WorkerPoolOptions};
262+
263+
let mut options = WorkerPoolOptions::new();
264+
options.idle_timeout_ms = Some(5000); // Terminate idle workers after 5 seconds
265+
init_worker_pool(options).await.unwrap();
266+
```
267+
268+
You can inspect the pool state using `num_active_workers()` to see how many workers are currently alive.
269+
255270
## FAQ
256271
1. _Why would you not want to use SharedArrayBuffers?_
257272

proc-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wasmworker-proc-macro"
3-
version = "0.2.1"
3+
version = "0.3.0"
44
edition = "2021"
55

66
description.workspace = true

0 commit comments

Comments
 (0)