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§
Sourcefn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
Spawns a new asynchronous task in the background, returning a Future JoinHandle
for it.
Provided Methods§
Sourcefn spawn_abortable<F>(&self, future: F) -> AbortableJoinHandle<F::Output> ⓘ
fn spawn_abortable<F>(&self, future: F) -> AbortableJoinHandle<F::Output> ⓘ
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.
Sourcefn dispatch<F>(&self, future: F)
fn dispatch<F>(&self, future: F)
Spawns a new asynchronous task in the background without an handle.
Basically the same as Executor::spawn
.
Sourcefn spawn_coroutine<T, F, Fut>(&self, f: F) -> CommunicationTask<T>
fn spawn_coroutine<T, F, Fut>(&self, f: F) -> CommunicationTask<T>
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.
Sourcefn spawn_coroutine_with_context<T, F, C, Fut>(
&self,
context: C,
f: F,
) -> CommunicationTask<T>
fn spawn_coroutine_with_context<T, F, C, Fut>( &self, context: C, f: F, ) -> CommunicationTask<T>
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.
Sourcefn spawn_unbounded_coroutine<T, F, Fut>(
&self,
f: F,
) -> UnboundedCommunicationTask<T>
fn spawn_unbounded_coroutine<T, F, Fut>( &self, f: F, ) -> UnboundedCommunicationTask<T>
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.
Sourcefn spawn_unbounded_coroutine_with_context<T, F, C, Fut>(
&self,
context: C,
f: F,
) -> UnboundedCommunicationTask<T>
fn spawn_unbounded_coroutine_with_context<T, F, C, Fut>( &self, context: C, f: F, ) -> UnboundedCommunicationTask<T>
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.