Skip to main content

TaskExecutor

Trait TaskExecutor 

Source
pub trait TaskExecutor: Send + Sync {
    // Required methods
    fn start_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
        work: BoxedTaskWork,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TaskHandle>, TaskStorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn cancel_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), TaskStorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn await_terminal<'life0, 'life1, 'async_trait>(
        &'life0 self,
        task_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Option<TaskStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for executing task work and managing runtime lifecycle.

Required Methods§

Source

fn start_task<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, work: BoxedTaskWork, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TaskHandle>, TaskStorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Start executing a task. Returns an opaque handle for cancellation.

Source

fn cancel_task<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), TaskStorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Cancel a running task by ID.

Source

fn await_terminal<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Option<TaskStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Block until a task reaches terminal status. Returns the terminal status, or None if the task is not tracked by this executor.

Implementors§