diff options
Diffstat (limited to 'tokio-executor/src/global.rs')
-rw-r--r-- | tokio-executor/src/global.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/tokio-executor/src/global.rs b/tokio-executor/src/global.rs index 47f7505c..1c4c53ff 100644 --- a/tokio-executor/src/global.rs +++ b/tokio-executor/src/global.rs @@ -1,7 +1,5 @@ use super::{Enter, Executor, SpawnError}; - use futures::{future, Future}; - use std::cell::Cell; /// Executes futures on the default executor for the current execution context. @@ -37,7 +35,7 @@ impl DefaultExecutor { } #[inline] - fn with_current<F: FnOnce(&mut Executor) -> R, R>(f: F) -> Option<R> { + fn with_current<F: FnOnce(&mut dyn Executor) -> R, R>(f: F) -> Option<R> { EXECUTOR.with( |current_executor| match current_executor.replace(State::Active) { State::Ready(executor_ptr) => { @@ -57,7 +55,7 @@ enum State { // default executor not defined Empty, // default executor is defined and ready to be used - Ready(*mut Executor), + Ready(*mut dyn Executor), // default executor is currently active (used to detect recursive calls) Active, } @@ -72,7 +70,7 @@ thread_local! { impl super::Executor for DefaultExecutor { fn spawn( &mut self, - future: Box<Future<Item = (), Error = ()> + Send>, + future: Box<dyn Future<Item = (), Error = ()> + Send>, ) -> Result<(), SpawnError> { DefaultExecutor::with_current(|executor| executor.spawn(future)) .unwrap_or_else(|| Err(SpawnError::shutdown())) @@ -144,19 +142,14 @@ where /// /// # Examples /// -/// ```rust -/// # extern crate futures; -/// # extern crate tokio_executor; -/// # use tokio_executor::spawn; -/// # pub fn dox() { +/// ```no_run +/// use tokio_executor::spawn; /// use futures::future::lazy; /// /// spawn(lazy(|| { /// println!("running on the default executor"); /// Ok(()) /// })); -/// # } -/// # pub fn main() {} /// ``` pub fn spawn<T>(future: T) where @@ -210,7 +203,7 @@ where }) } -unsafe fn hide_lt<'a>(p: *mut (Executor + 'a)) -> *mut (Executor + 'static) { +unsafe fn hide_lt<'a>(p: *mut (dyn Executor + 'a)) -> *mut (dyn Executor + 'static) { use std::mem; mem::transmute(p) } |