Skip to main content

Task

Trait Task 

Source
pub trait Task: Send + 'static {
    type Output: Send + 'static;

    // Required methods
    fn execute(self) -> Self::Output;
    fn context(&self) -> &TaskContext;

    // Provided methods
    fn is_stealable(&self) -> bool { ... }
    fn estimated_cost(&self) -> u32 { ... }
}
Expand description

The core trait for executable tasks in the Moirai runtime.

Required Associated Types§

Source

type Output: Send + 'static

The output type produced by this task.

Required Methods§

Source

fn execute(self) -> Self::Output

Execute this task to completion.

Source

fn context(&self) -> &TaskContext

Get the task context for scheduling and debugging.

Provided Methods§

Source

fn is_stealable(&self) -> bool

Check if this task can be stolen by another thread.

Source

fn estimated_cost(&self) -> u32

Estimate the computational cost of this task (for load balancing).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Task for Box<T>
where T: Task,

Available on crate feature std only.

Implementors§

Source§

impl Task for Group

Source§

impl<F, P, R> Task for Parameterized<F, P>
where F: FnOnce(P) -> R + Send + 'static, P: Send + 'static, R: Send + 'static,

Source§

impl<F, R> Task for Closure<F, R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Source§

impl<F> Task for Spawner<F>
where F: FnOnce() + Send + 'static,

Source§

impl<T, F, U> Task for Chained<T, F>
where T: Task, F: FnOnce(<T as Task>::Output) -> U + Send + 'static, U: Send + 'static,

Source§

impl<T, F, U> Task for Mapped<T, F>
where T: Task, F: FnOnce(<T as Task>::Output) -> U + Send + 'static, U: Send + 'static,

Source§

impl<T> Task for ContextualTask<T>
where T: Task,

Source§

type Output = <T as Task>::Output