فهرست منبع

Upgrade to tokio 3.0.

Jing Yang 5 سال پیش
والد
کامیت
4fc9becbe4
2فایلهای تغییر یافته به همراه4 افزوده شده و 5 حذف شده
  1. 1 1
      Cargo.toml
  2. 3 4
      src/network.rs

+ 1 - 1
Cargo.toml

@@ -9,4 +9,4 @@ bytes = "0.5.6"
 futures = { version = "0.3.5", features = ["thread-pool"] }
 parking_lot = "0.11.0"
 rand = "0.7.3"
-tokio = { version = "0.2.22", features = ["rt-threaded", "time"] }
+tokio = { version = "0.3", features = ["rt-multi-thread", "time", "parking_lot"] }

+ 3 - 4
src/network.rs

@@ -145,7 +145,7 @@ impl Network {
     const SHUTDOWN_DELAY: Duration = Duration::from_micros(20);
 
     async fn delay_for_millis(milli_seconds: u64) {
-        tokio::time::delay_for(Duration::from_millis(milli_seconds)).await;
+        tokio::time::sleep(Duration::from_millis(milli_seconds)).await;
     }
 
     async fn serve_rpc(network: Arc<Mutex<Self>>, rpc: RpcOnWire) {
@@ -256,9 +256,8 @@ impl Network {
         let network = Arc::new(Mutex::new(network));
 
         // Using tokio instead of futures-rs, because we need timer futures.
-        let thread_pool = tokio::runtime::Builder::new()
-            .threaded_scheduler()
-            .core_threads(10)
+        let thread_pool = tokio::runtime::Builder::new_multi_thread()
+            .worker_threads(10)
             .max_threads(20)
             .thread_name("network")
             .enable_time()