mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-21 00:00:10 +02:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user