diff options
Diffstat (limited to 'futures/src/executor')
| -rw-r--r-- | futures/src/executor/async_std.rs | 1 | ||||
| -rw-r--r-- | futures/src/executor/thread_pool.rs | 1 | ||||
| -rw-r--r-- | futures/src/executor/tokio.rs | 4 | ||||
| -rw-r--r-- | futures/src/executor/tokio_old.rs | 21 | 
4 files changed, 26 insertions, 1 deletions
| diff --git a/futures/src/executor/async_std.rs b/futures/src/executor/async_std.rs index 27949e31..471be369 100644 --- a/futures/src/executor/async_std.rs +++ b/futures/src/executor/async_std.rs @@ -3,6 +3,7 @@ use crate::Executor;  use futures::Future;  /// An `async-std` runtime. +#[cfg_attr(docsrs, doc(cfg(feature = "async-std")))]  #[derive(Debug)]  pub struct AsyncStd; diff --git a/futures/src/executor/thread_pool.rs b/futures/src/executor/thread_pool.rs index 1ec5bf69..a6c6168e 100644 --- a/futures/src/executor/thread_pool.rs +++ b/futures/src/executor/thread_pool.rs @@ -3,6 +3,7 @@ use crate::Executor;  use futures::Future;  /// A thread pool runtime for futures. +#[cfg_attr(docsrs, doc(cfg(feature = "thread-pool")))]  pub type ThreadPool = futures::executor::ThreadPool;  impl Executor for futures::executor::ThreadPool { diff --git a/futures/src/executor/tokio.rs b/futures/src/executor/tokio.rs index 20802ceb..c6a21cec 100644 --- a/futures/src/executor/tokio.rs +++ b/futures/src/executor/tokio.rs @@ -3,6 +3,7 @@ use crate::Executor;  use futures::Future;  /// A `tokio` runtime. +#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]  pub type Tokio = tokio::runtime::Runtime;  impl Executor for Tokio { @@ -15,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) +    } +} | 
