Closed
Description
The executor trait looks like this:
pub trait Executor {
fn spawn_obj(
&mut self,
future: FutureObj<'static, ()>,
) -> Result<(), SpawnObjError>;
fn status(&self) -> Result<(), SpawnErrorKind> { ... }
// Planned
fn spawn(
&mut self,
future: dyn Future<Output = ()> + Send + 'static,
) -> Result<(), SpawnError> { ... }
}
And here's how using it looks like (uses upcoming boxed
combinator):
ctx.executor().spawn_obj(future.boxed().into());
// Planned
ctx.executor().spawn(future);
I would like to define ExecutorExt
:
pub trait ExecutorExt {
fn spawn_obj_with_handle<T>(
&mut self,
future: FutureObj<'static, T>,
) -> Result<JoinHandle<T>, SpawnObjError>;
// Planned
fn spawn_with_handle<T>(
&mut self,
future: dyn Future<Output = T> + Send + 'static,
) -> Result<JoinHandle<T>, SpawnError>;
}
TL;DR Move our existing spawn_with_handle
function into ExecutorExt
Metadata
Metadata
Assignees
Labels
No labels