pub trait Executor: Send + Sync {
type Execution<R, E>
where R: Send + 'static,
E: Display + Send + 'static;
// Required method
fn call<C, R, E>(&self, task: C) -> Self::Execution<R, E>
where C: Callable<R, E> + Send + 'static,
R: Send + 'static,
E: Display + Send + 'static;
// Provided method
fn execute<T, E>(&self, task: T) -> Self::Execution<(), E>
where T: Runnable<E> + Send + 'static,
E: Display + Send + 'static { ... }
}Expand description
Executes fallible one-time tasks according to an implementation-defined strategy.
Executor models an execution strategy, not a managed task service. An
executor may run a task immediately, retry it, delay it, schedule it on
another runtime, or return a handle that represents work running elsewhere.
The associated Self::Execution type describes how this executor exposes
the result of a single execution.
Required Associated Types§
Sourcetype Execution<R, E>
where
R: Send + 'static,
E: Display + Send + 'static
type Execution<R, E> where R: Send + 'static, E: Display + Send + 'static
The result carrier returned for one execution.
Implementations choose the carrier that matches their execution model.
For example, a direct executor can use Result<R, E>, while a threaded
executor can use a task handle and a future-backed executor can use a
future.
Required Methods§
Provided Methods§
Sourcefn execute<T, E>(&self, task: T) -> Self::Execution<(), E>
fn execute<T, E>(&self, task: T) -> Self::Execution<(), E>
Executes a runnable task and returns this executor’s result carrier.
This is the unit-returning counterpart of Self::call. The returned
carrier reports the runnable’s Result<(), E> according to the concrete
executor’s execution model.
§Parameters
task- The fallible action to execute.
§Returns
The execution carrier for the submitted runnable.
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.