Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExecutorExt #1142

Closed
MajorBreakfast opened this issue Jul 30, 2018 · 1 comment
Closed

ExecutorExt #1142

MajorBreakfast opened this issue Jul 30, 2018 · 1 comment

Comments

@MajorBreakfast
Copy link
Contributor

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

@MajorBreakfast
Copy link
Contributor Author

Closed by #1156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant