Skip to content

ExecutorExt #1142

Closed
Closed
@MajorBreakfast

Description

@MajorBreakfast

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions