From 782dd2f5222bfef5e12aa576a821da21126505b7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 25 Nov 2020 03:06:24 +0100 Subject: Introduce `tokio_old` feature This feature allows users to rely on the `0.2` version of `tokio` while the async ecosystem upgrades to the latest version. --- futures/src/executor/tokio_old.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 futures/src/executor/tokio_old.rs (limited to 'futures/src/executor') 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 { + tokio_old::runtime::Runtime::new() + } + + fn spawn(&self, future: impl Future + Send + 'static) { + let _ = tokio_old::runtime::Runtime::spawn(self, future); + } + + fn enter(&self, f: impl FnOnce() -> R) -> R { + tokio_old::runtime::Runtime::enter(self, f) + } +} -- cgit