summaryrefslogtreecommitdiffstats
path: root/futures/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-11-25 04:24:44 +0100
committerLibravatar GitHub <noreply@github.com>2020-11-25 04:24:44 +0100
commit87c9df294c79d73ff67a8d9a036cf9ddff24c52f (patch)
tree167a3a63519d20e67cf227441b938d8a9b0b584d /futures/src
parent8f081bad7756e16a4eb0ca4dcb1144fc47de5e9b (diff)
parent782dd2f5222bfef5e12aa576a821da21126505b7 (diff)
downloadiced-87c9df294c79d73ff67a8d9a036cf9ddff24c52f.tar.gz
iced-87c9df294c79d73ff67a8d9a036cf9ddff24c52f.tar.bz2
iced-87c9df294c79d73ff67a8d9a036cf9ddff24c52f.zip
Merge pull request #595 from valbendan/master
upgrade tokio to latest version(v0.3)
Diffstat (limited to 'futures/src')
-rw-r--r--futures/src/executor.rs6
-rw-r--r--futures/src/executor/tokio.rs3
-rw-r--r--futures/src/executor/tokio_old.rs21
-rw-r--r--futures/src/lib.rs2
-rw-r--r--futures/src/time.rs8
5 files changed, 37 insertions, 3 deletions
diff --git a/futures/src/executor.rs b/futures/src/executor.rs
index cbd34ee8..13abe430 100644
--- a/futures/src/executor.rs
+++ b/futures/src/executor.rs
@@ -7,6 +7,9 @@ mod thread_pool;
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
mod tokio;
+#[cfg(all(not(target_arch = "wasm32"), feature = "tokio_old"))]
+mod tokio_old;
+
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
mod async_std;
@@ -21,6 +24,9 @@ pub use thread_pool::ThreadPool;
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
pub use self::tokio::Tokio;
+#[cfg(all(not(target_arch = "wasm32"), feature = "tokio_old"))]
+pub use self::tokio_old::TokioOld;
+
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
pub use self::async_std::AsyncStd;
diff --git a/futures/src/executor/tokio.rs b/futures/src/executor/tokio.rs
index a730bce8..c6a21cec 100644
--- a/futures/src/executor/tokio.rs
+++ b/futures/src/executor/tokio.rs
@@ -16,6 +16,7 @@ impl Executor for Tokio {
}
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
- tokio::runtime::Runtime::enter(self, f)
+ let _guard = tokio::runtime::Runtime::enter(self);
+ f()
}
}
diff --git a/futures/src/executor/tokio_old.rs b/futures/src/executor/tokio_old.rs
new file mode 100644
index 00000000..d64729fa
--- /dev/null
+++ b/futures/src/executor/tokio_old.rs
@@ -0,0 +1,21 @@
+use crate::Executor;
+
+use futures::Future;
+
+/// An old `tokio` runtime.
+#[cfg_attr(docsrs, doc(cfg(feature = "tokio_old")))]
+pub type TokioOld = tokio_old::runtime::Runtime;
+
+impl Executor for TokioOld {
+ fn new() -> Result<Self, futures::io::Error> {
+ tokio_old::runtime::Runtime::new()
+ }
+
+ fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
+ let _ = tokio_old::runtime::Runtime::spawn(self, future);
+ }
+
+ fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
+ tokio_old::runtime::Runtime::enter(self, f)
+ }
+}
diff --git a/futures/src/lib.rs b/futures/src/lib.rs
index 46fc59fc..f46db449 100644
--- a/futures/src/lib.rs
+++ b/futures/src/lib.rs
@@ -15,7 +15,7 @@ pub mod executor;
pub mod subscription;
#[cfg(all(
- any(feature = "tokio", feature = "async-std"),
+ any(feature = "tokio", feature = "tokio_old", feature = "async-std"),
not(target_arch = "wasm32")
))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tokio", feature = "async-std"))))]
diff --git a/futures/src/time.rs b/futures/src/time.rs
index e87b4a83..ec007d88 100644
--- a/futures/src/time.rs
+++ b/futures/src/time.rs
@@ -41,7 +41,10 @@ where
}
}
-#[cfg(all(feature = "tokio", not(feature = "async-std")))]
+#[cfg(all(
+ any(feature = "tokio", feature = "tokio_old"),
+ not(feature = "async-std")
+))]
impl<H, E> subscription::Recipe<H, E> for Every
where
H: std::hash::Hasher,
@@ -61,6 +64,9 @@ where
) -> futures::stream::BoxStream<'static, Self::Output> {
use futures::stream::StreamExt;
+ #[cfg(feature = "tokio_old")]
+ use tokio_old as tokio;
+
let start = tokio::time::Instant::now() + self.0;
tokio::time::interval_at(start, self.0)