diff options
Diffstat (limited to '')
-rw-r--r-- | futures/src/executor.rs | 6 | ||||
-rw-r--r-- | futures/src/executor/tokio_old.rs | 21 |
2 files changed, 27 insertions, 0 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_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) + } +} |