mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
executor: add TypedExecutor (#993)
Adds a `TypedExecutor` trait that describes how to spawn futures of a specific type. This is useful for implementing functions that are generic over an executor and wish to support both `Send` and `!Send` cases.
This commit is contained in:
@@ -176,6 +176,19 @@ impl<'a> tokio_executor::Executor for &'a Sender {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> tokio_executor::TypedExecutor<T> for Sender
|
||||
where
|
||||
T: Future<Item = (), Error = ()> + Send + 'static,
|
||||
{
|
||||
fn status(&self) -> Result<(), tokio_executor::SpawnError> {
|
||||
tokio_executor::Executor::status(self)
|
||||
}
|
||||
|
||||
fn spawn(&mut self, future: T) -> Result<(), SpawnError> {
|
||||
tokio_executor::Executor::spawn(self, Box::new(future))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> future::Executor<T> for Sender
|
||||
where
|
||||
T: Future<Item = (), Error = ()> + Send + 'static,
|
||||
|
||||
Reference in New Issue
Block a user