From fc872ea03f1803fbab9b28280fef54ca0430c483 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Fri, 11 Oct 2019 10:25:58 -0700 Subject: [PATCH] Remove async-await feature of futures. --- zebra-network/Cargo.toml | 2 +- zebra-network/src/timestamp_collector.rs | 22 ++++++++-------------- zebrad/Cargo.toml | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index 4b7dfbab2..9652bca68 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -21,7 +21,7 @@ pin-project = "0.4" indexmap = { version = "1.2", default-features = false } tokio = "=0.2.0-alpha.6" -futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] } +futures-preview = "=0.3.0-alpha.19" tracing = "0.1" tracing-futures = { version = "0.1", features = ["tokio-alpha"], default-features = false } diff --git a/zebra-network/src/timestamp_collector.rs b/zebra-network/src/timestamp_collector.rs index ad973a10d..a0125793c 100644 --- a/zebra-network/src/timestamp_collector.rs +++ b/zebra-network/src/timestamp_collector.rs @@ -87,21 +87,15 @@ impl TimestampCollector { // Construct and then spawn a worker. let worker = async move { - use futures::select; + use futures::future::{self, Either}; loop { - select! { - _ = shutdown_rx.next() => return, - msg = worker_rx.next() => { - match msg { - Some(event) => { - data2 - .lock() - .expect("mutex should be unpoisoned") - .update(event) - } - None => return, - } - } + match future::select(shutdown_rx.next(), worker_rx.next()).await { + Either::Left((_, _)) => return, // shutdown signal + Either::Right((None, _)) => return, // all workers are gone + Either::Right((Some(event), _)) => data2 + .lock() + .expect("mutex should be unpoisoned") + .update(event), } } }; diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index b1c38d8aa..6652ac473 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -15,7 +15,7 @@ serde = { version = "1", features = ["serde_derive"] } toml = "0.5" tokio = "=0.2.0-alpha.6" -futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] } +futures-preview = "=0.3.0-alpha.19" tracing = "0.1" tracing-futures = { version = "0.1", features = ["tokio-alpha"], default-features = false }