Trait Executor

Source
pub trait Executor {
    // Required method
    fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> 
       where F: Future + Send + 'static,
             F::Output: Send + 'static;

    // Provided methods
    fn spawn_abortable<F>(&self, future: F) -> AbortableJoinHandle<F::Output> 
       where F: Future + Send + 'static,
             F::Output: Send + 'static { ... }
    fn dispatch<F>(&self, future: F)
       where F: Future + Send + 'static,
             F::Output: Send + 'static { ... }
    fn spawn_coroutine<T, F, Fut>(&self, f: F) -> CommunicationTask<T>
       where F: FnMut(Receiver<T>) -> Fut,
             Fut: Future<Output = ()> + Send + 'static { ... }
    fn spawn_coroutine_with_context<T, F, C, Fut>(
        &self,
        context: C,
        f: F,
    ) -> CommunicationTask<T>
       where F: FnMut(C, Receiver<T>) -> Fut,
             Fut: Future<Output = ()> + Send + 'static { ... }
    fn spawn_unbounded_coroutine<T, F, Fut>(
        &self,
        f: F,
    ) -> UnboundedCommunicationTask<T>
       where F: FnMut(UnboundedReceiver<T>) -> Fut,
             Fut: Future<Output = ()> + Send + 'static { ... }
    fn spawn_unbounded_coroutine_with_context<T, F, C, Fut>(
        &self,
        context: C,
        f: F,
    ) -> UnboundedCommunicationTask<T>
       where F: FnMut(C, UnboundedReceiver<T>) -> Fut,
             Fut: Future<Output = ()> + Send + 'static { ... }
}

Required Methods§

Source

fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns a new asynchronous task in the background, returning a Future JoinHandle for it.

Provided Methods§

Source

fn spawn_abortable<F>(&self, future: F) -> AbortableJoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns a new asynchronous task in the background, returning an abortable handle that will cancel the task once the handle is dropped.

Note: This function is used if the task is expected to run until the handle is dropped. It is recommended to use Executor::spawn or Executor::dispatch otherwise.

Source

fn dispatch<F>(&self, future: F)
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns a new asynchronous task in the background without an handle. Basically the same as Executor::spawn.

Source

fn spawn_coroutine<T, F, Fut>(&self, f: F) -> CommunicationTask<T>
where F: FnMut(Receiver<T>) -> Fut, Fut: Future<Output = ()> + Send + 'static,

Spawns a new asynchronous task that accepts messages to the task using channels. This function returns a handle that allows sending a message, or if there is no reference to the handle at all (in other words, all handles are dropped), the task would be aborted.

Source

fn spawn_coroutine_with_context<T, F, C, Fut>( &self, context: C, f: F, ) -> CommunicationTask<T>
where F: FnMut(C, Receiver<T>) -> Fut, Fut: Future<Output = ()> + Send + 'static,

Spawns a new asynchronous task with provided context that accepts messages to the task using channels. This function returns a handle that allows sending a message, or if there is no reference to the handle at all (in other words, all handles are dropped), the task would be aborted.

Source

fn spawn_unbounded_coroutine<T, F, Fut>( &self, f: F, ) -> UnboundedCommunicationTask<T>
where F: FnMut(UnboundedReceiver<T>) -> Fut, Fut: Future<Output = ()> + Send + 'static,

Spawns a new asynchronous task that accepts messages to the task using channels. This function returns a handle that allows sending a message, or if there is no reference to the handle at all (in other words, all handles are dropped), the task would be aborted.

Source

fn spawn_unbounded_coroutine_with_context<T, F, C, Fut>( &self, context: C, f: F, ) -> UnboundedCommunicationTask<T>
where F: FnMut(C, UnboundedReceiver<T>) -> Fut, Fut: Future<Output = ()> + Send + 'static,

Spawns a new asynchronous task with provided context that accepts messages to the task using channels. This function returns a handle that allows sending a message, or if there is no reference to the handle at all (in other words, all handles are dropped), the task would be aborted.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<E> Executor for Arc<E>
where E: Executor,

Source§

fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Implementors§