executor: remove Executor & TypedExecutor traits (#1724)

The `Executor` trait is sub-optimal as it forces a `Box<dyn Future>` to
spawn. Instead, `tokio::spawn` delegates to the specific runtime
implementation set for the current execution context.

`TypedExecutor`, while useful, has seen limited adoption. As such, it is
removed from `tokio` proper. Moving it to `tokio-util` is a possibility
that can be explored as follow up work.
This commit is contained in:
Carl Lerche
2019-11-01 13:50:17 -07:00
committed by GitHub
parent d70c928d88
commit 3e7d0be51d
14 changed files with 26 additions and 662 deletions
-17
View File
@@ -1,6 +1,5 @@
use crate::executor::park::{Park, Unpark};
use crate::executor::task::{self, JoinHandle, Schedule, Task};
use crate::executor::Executor;
use std::cell::UnsafeCell;
use std::collections::VecDeque;
@@ -294,22 +293,6 @@ impl Schedule for Scheduler {
}
}
impl Executor for &Scheduler {
fn spawn(
&mut self,
future: std::pin::Pin<Box<dyn Future<Output = ()> + Send>>,
) -> Result<(), crate::executor::SpawnError> {
// Safety: This implementation should only be called by `global.rs` from
// the thread local.
//
// TODO: Delete this implementation.
unsafe {
Scheduler::spawn_background(self, future);
}
Ok(())
}
}
impl<P> Drop for CurrentThread<P>
where
P: Park,