diff --git a/crates/napi/src/threadsafe_function.rs b/crates/napi/src/threadsafe_function.rs index 369b69a0..a6e791b8 100644 --- a/crates/napi/src/threadsafe_function.rs +++ b/crates/napi/src/threadsafe_function.rs @@ -246,8 +246,6 @@ impl ThreadsafeFunction { ) })?; - check_status!(unsafe { sys::napi_acquire_threadsafe_function(raw_tsfn) })?; - Ok(ThreadsafeFunction { handle: Arc::new(ThreadsafeFunctionHandle { raw: raw_tsfn, diff --git a/examples/napi/src/threadsafe_function.rs b/examples/napi/src/threadsafe_function.rs index 546e870e..fc762e88 100644 --- a/examples/napi/src/threadsafe_function.rs +++ b/examples/napi/src/threadsafe_function.rs @@ -8,14 +8,12 @@ use napi::{ #[napi] pub fn call_threadsafe_function(callback: JsFunction) -> Result<()> { - let tsfn: ThreadsafeFunction = callback - .create_threadsafe_function(0, |ctx| { - ctx.env.create_uint32(ctx.value + 1).map(|v| vec![v]) - })?; + let tsfn: ThreadsafeFunction = + callback.create_threadsafe_function(0, |ctx| Ok(vec![ctx.value + 1]))?; for n in 0..100 { let tsfn = tsfn.clone(); thread::spawn(move || { - tsfn.call(Ok(n), ThreadsafeFunctionCallMode::Blocking); + tsfn.call(Ok(n), ThreadsafeFunctionCallMode::NonBlocking); }); } Ok(())