pub trait Executor: Send + Sync {
// Required method
fn call<C, R, E>(
&self,
task: C,
) -> Result<TrackedTask<R, E>, SubmissionError>
where C: Callable<R, E> + Send + 'static,
R: Send + 'static,
E: Send + 'static;
// Provided method
fn execute<T, E>(
&self,
task: T,
) -> Result<TrackedTask<(), E>, SubmissionError>
where T: Runnable<E> + Send + 'static,
E: 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, or schedule it on
another runtime. Accepted task results are always exposed through a
TrackedTask. The outer Result returned by Self::call and
Self::execute reports submission failure only.
Required Methods§
Sourcefn call<C, R, E>(&self, task: C) -> Result<TrackedTask<R, E>, SubmissionError>
fn call<C, R, E>(&self, task: C) -> Result<TrackedTask<R, E>, SubmissionError>
Submits a callable task and returns a tracked task handle.
§Parameters
task- The fallible computation to execute.
§Returns
A tracked handle for the accepted callable.
§Errors
Returns SubmissionError if this executor cannot accept the callable.
Provided Methods§
Sourcefn execute<T, E>(&self, task: T) -> Result<TrackedTask<(), E>, SubmissionError>
fn execute<T, E>(&self, task: T) -> Result<TrackedTask<(), E>, SubmissionError>
Submits a runnable task and returns a tracked task handle.
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
A tracked handle for the accepted runnable.
§Errors
Returns SubmissionError if this executor cannot accept the 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.