From 1615cb1f1ab694d84d57895101857069a317c58e Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Sat, 21 Dec 2024 21:09:22 +0000 Subject: [PATCH] Expose `init_thread_pool` in docs --- README.md | 1 + src/lib.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9044679..cbba6db 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ In order to reduce risk of breakages, it's strongly recommended to use a fixed n The easiest way to configure those flags is: 1. Put the following in a `rust-toolchain.toml` file in your project directory: + ```toml [toolchain] channel = "nightly-2024-08-02" diff --git a/src/lib.rs b/src/lib.rs index c217a07..a96ca67 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,8 +106,13 @@ impl wbg_rayon_PoolBuilder { } } +/// Function exposed as `initThreadPool` to JS (see the main docs). +/// +/// Normally, you'd invoke this function from JS to initialize the thread pool. +/// However, if you strongly prefer, you can use [wasm-bindgen-futures](https://rustwasm.github.io/wasm-bindgen/reference/js-promises-and-rust-futures.html) to invoke and await this function from Rust. +/// +/// Note that doing so comes with extra initialization and Wasm size overhead for the JS<->Rust Promise integration. #[wasm_bindgen(js_name = initThreadPool)] -#[doc(hidden)] pub fn init_thread_pool(num_threads: usize) -> Promise { start_workers( wasm_bindgen::module(),