chore: tokio@0.3
This commit is contained in:
parent
062370ba5c
commit
64d66a2261
5 changed files with 7 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -26,7 +26,7 @@ pub(crate) fn get_tokio_sender() -> &'static mpsc::Sender<Message> {
|
|||
.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<Message> {
|
|||
}
|
||||
|
||||
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)))
|
||||
|
|
|
@ -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"}
|
||||
|
|
|
@ -75,7 +75,7 @@ pub fn test_tokio_readfile(ctx: CallContext) -> Result<JsUndefined> {
|
|||
.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 {
|
||||
|
|
Loading…
Reference in a new issue