Skip to content

Commit

Permalink
Only assert under debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Dec 21, 2024
1 parent 7fd82a7 commit 79c5850
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ extern "C" {
#[wasm_bindgen]
impl wbg_rayon_PoolBuilder {
fn new(num_threads: usize) -> Self {
#[cfg(debug_assertions)]
if num_threads == 0 {
wasm_bindgen::throw_str("Number of threads must be greater than zero.");
}
let (sender, receiver) = bounded(num_threads);
Self {
num_threads,
Expand Down
4 changes: 0 additions & 4 deletions src/workerHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ waitForMsgType(self, 'wasm_bindgen_worker_init').then(async data => {
});

export async function startWorkers(module, memory, builder) {
if (builder.numThreads() === 0) {
throw new Error(`num_threads must be > 0.`);
}

const workerInit = {
type: 'wasm_bindgen_worker_init',
init: { module, memory },
Expand Down
4 changes: 0 additions & 4 deletions src/workerHelpers.no-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ waitForMsgType(self, 'wasm_bindgen_worker_init').then(async data => {
});

export async function startWorkers(module, memory, builder) {
if (builder.numThreads() === 0) {
throw new Error(`num_threads must be > 0.`);
}

const workerInit = {
type: 'wasm_bindgen_worker_init',
init: { module, memory },
Expand Down

0 comments on commit 79c5850

Please sign in to comment.