diff --git a/napi/Cargo.toml b/napi/Cargo.toml index 0b834b5b..ab9a8357 100644 --- a/napi/Cargo.toml +++ b/napi/Cargo.toml @@ -27,9 +27,9 @@ optional = true version = "0.3" [dependencies.tokio] -features = ["rt-core", "rt-threaded", "sync"] +features = ["rt", "rt-multi-thread", "sync"] optional = true -version = "0.2" +version = "0.3" [dependencies.once_cell] optional = true diff --git a/napi/src/env.rs b/napi/src/env.rs index 498f3689..7261b32f 100644 --- a/napi/src/env.rs +++ b/napi/src/env.rs @@ -640,7 +640,7 @@ impl Env { let future_promise = promise::FuturePromise::create(raw_env, raw_deferred, Box::from(resolver))?; let future_to_resolve = promise::resolve_from_future(future_promise.start()?, fut); - let mut sender = get_tokio_sender().clone(); + let sender = get_tokio_sender().clone(); sender .try_send(Message::Task(Box::pin(future_to_resolve))) .map_err(|e| match e { diff --git a/napi/src/tokio_rt.rs b/napi/src/tokio_rt.rs index 387cee6e..c751bf57 100644 --- a/napi/src/tokio_rt.rs +++ b/napi/src/tokio_rt.rs @@ -26,7 +26,7 @@ pub(crate) fn get_tokio_sender() -> &'static mpsc::Sender { .unwrap_or(100); let (sender, mut receiver) = mpsc::channel(buffer_size); spawn(move || { - let mut rt = Runtime::new().expect("Failed to create tokio runtime"); + let rt = Runtime::new().expect("Failed to create tokio runtime"); rt.block_on(async { loop { match receiver.recv().await { @@ -44,7 +44,7 @@ pub(crate) fn get_tokio_sender() -> &'static mpsc::Sender { } pub unsafe extern "C" fn shutdown(_data: *mut c_void) { - let mut sender = get_tokio_sender().clone(); + let sender = get_tokio_sender().clone(); sender .try_send(Message::Shutdown) .map_err(|e| Error::from_reason(format!("Shutdown tokio runtime failed: {}", e))) diff --git a/test_module/Cargo.toml b/test_module/Cargo.toml index 7ba133c8..80c7d7a6 100644 --- a/test_module/Cargo.toml +++ b/test_module/Cargo.toml @@ -15,7 +15,7 @@ serde = "1" serde_bytes = "0.11" serde_derive = "1" serde_json = "1" -tokio = {version = "0.2", features = ["default", "fs"]} +tokio = {version = "0.3", features = ["default", "fs"]} [build-dependencies] napi-build = {path = "../build"} diff --git a/test_module/src/napi4/tsfn.rs b/test_module/src/napi4/tsfn.rs index a4a01608..c456118d 100644 --- a/test_module/src/napi4/tsfn.rs +++ b/test_module/src/napi4/tsfn.rs @@ -75,7 +75,7 @@ pub fn test_tokio_readfile(ctx: CallContext) -> Result { .create_buffer_with_data(ctx.value) .map(|v| vec![v.into_raw()]) })?; - let mut rt = tokio::runtime::Runtime::new() + let rt = tokio::runtime::Runtime::new() .map_err(|e| Error::from_reason(format!("Create tokio runtime failed {}", e)))?; rt.block_on(async move {