From b8c52bffadc2d9e498ca63b4396c2edfa4502e5f Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Sun, 13 Dec 2020 15:40:41 -0800 Subject: [PATCH 1/3] Starting to upgrade to tokio 0.3 --- Cargo.toml | 5 ++--- src/async_turtle.rs | 2 +- src/ipc_protocol/async_ipc_receiver.rs | 2 +- src/renderer_server/animation.rs | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6bb2f91e..e9f36f1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,14 +59,13 @@ features = [ ] [dependencies.tokio] -version = "0.2" +version = "0.3" default-features = false features = [ "process", "io-std", "io-util", - "rt-threaded", - "blocking", + "rt-multi-thread", "sync", "stream", "time", diff --git a/src/async_turtle.rs b/src/async_turtle.rs index a99eee1b..055c01f0 100644 --- a/src/async_turtle.rs +++ b/src/async_turtle.rs @@ -98,7 +98,7 @@ impl AsyncTurtle { return; } - time::delay_for(time::Duration::from_millis((secs * 1000.0) as u64)).await + time::sleep(time::Duration::from_millis((secs * 1000.0) as u64)).await } pub async fn arc_left(&mut self, radius: Distance, extent: Angle) { diff --git a/src/ipc_protocol/async_ipc_receiver.rs b/src/ipc_protocol/async_ipc_receiver.rs index 7d3f0f86..d3822122 100644 --- a/src/ipc_protocol/async_ipc_receiver.rs +++ b/src/ipc_protocol/async_ipc_receiver.rs @@ -30,7 +30,7 @@ impl AsyncIpcReceiver { // disconnected. This allows callers of `recv` to detect the disconnection. let next_value = ipc_receiver.recv(); - let value_sender: oneshot::Sender<_> = match handle.block_on(receiver.recv()) { + let value_sender: oneshot::Sender<_> = match receiver.blocking_recv() { Some(value_sender) => value_sender, // The sender for this channel only drops when the main thread has stopped, // so it's pretty safe to stop here diff --git a/src/renderer_server/animation.rs b/src/renderer_server/animation.rs index 5215b464..df84d517 100644 --- a/src/renderer_server/animation.rs +++ b/src/renderer_server/animation.rs @@ -483,7 +483,7 @@ async fn animation_loop( }, // Trigger an update once the next update time has elapsed - _ = time::delay_until(next_update) => { + _ = time::sleep_until(next_update) => { let now = time::Instant::now(); handle_handler_result(update_animations( From ecbe04962d4774d07ea760a0402211f1c6067c07 Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Sun, 13 Dec 2020 16:02:12 -0800 Subject: [PATCH 2/3] Replaced handle.block_on with blocking_send --- src/renderer_server/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer_server/main.rs b/src/renderer_server/main.rs index de0c81ce..2202bb3c 100644 --- a/src/renderer_server/main.rs +++ b/src/renderer_server/main.rs @@ -278,7 +278,7 @@ pub fn run_main( GlutinEvent::LoopDestroyed => { // Notify the server that it should shutdown, ignoring the error if the channel has // been dropped since that just means that the server task has ended already - handle.block_on(server_shutdown.send(())).unwrap_or(()); + server_shutdown.blocking_send(()).unwrap_or(()); }, _ => {}, From 386e61dea867791e1de260f7d2efe97d187187cd Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Fri, 25 Dec 2020 16:50:54 -0800 Subject: [PATCH 3/3] Updated to tokio v1.0 --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9f36f1b..f39c1bca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ features = [ ] [dependencies.tokio] -version = "0.3" +version = "1.0" default-features = false features = [ "process", @@ -67,7 +67,6 @@ features = [ "io-util", "rt-multi-thread", "sync", - "stream", "time", "macros", ]