Skip to main content

Executor

Trait Executor 

Source
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§

Source

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,

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§

Source

fn execute<T, E>(&self, task: T) -> Result<TrackedTask<(), E>, SubmissionError>
where T: Runnable<E> + Send + 'static, E: Send + 'static,

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.

Implementors§