TaskScheduler

Trait TaskScheduler 

Source
pub trait TaskScheduler: Send + Sync {
    // Required methods
    fn schedule_task(&mut self, task: ExecutionTask) -> SklResult<TaskHandle>;
    fn schedule_batch(
        &mut self,
        tasks: Vec<ExecutionTask>,
    ) -> SklResult<Vec<TaskHandle>>;
    fn cancel_task(&mut self, handle: TaskHandle) -> SklResult<()>;
    fn get_status(&self) -> SchedulerStatus;
    fn update_config(&mut self, config: SchedulerConfig) -> SklResult<()>;
    fn shutdown_gracefully(
        &mut self,
    ) -> impl Future<Output = SklResult<()>> + Send;
    fn get_next_task(&mut self) -> Option<(ExecutionTask, TaskHandle)>;
    fn mark_task_completed(&mut self, handle: &TaskHandle) -> SklResult<()>;
    fn mark_task_failed(
        &mut self,
        handle: &TaskHandle,
        error: String,
    ) -> SklResult<()>;
}
Expand description

Task scheduler trait for pluggable scheduling implementations

Provides a flexible interface for different scheduling strategies that can be swapped based on workload characteristics and requirements.

Required Methods§

Source

fn schedule_task(&mut self, task: ExecutionTask) -> SklResult<TaskHandle>

Schedule a single task for execution

§Arguments
  • task - The task to schedule
§Returns

A task handle for tracking and management

Source

fn schedule_batch( &mut self, tasks: Vec<ExecutionTask>, ) -> SklResult<Vec<TaskHandle>>

Schedule multiple tasks as a batch

§Arguments
  • tasks - Vector of tasks to schedule
§Returns

Vector of task handles in the same order

Source

fn cancel_task(&mut self, handle: TaskHandle) -> SklResult<()>

Cancel a scheduled task

§Arguments
  • handle - Handle of the task to cancel
§Returns

Success or error if cancellation fails

Source

fn get_status(&self) -> SchedulerStatus

Get current scheduler status and metrics

§Returns

Current scheduler status information

Source

fn update_config(&mut self, config: SchedulerConfig) -> SklResult<()>

Update scheduler configuration

§Arguments
  • config - New scheduler configuration
§Returns

Success or error if configuration update fails

Source

fn shutdown_gracefully(&mut self) -> impl Future<Output = SklResult<()>> + Send

Shutdown scheduler gracefully

§Returns

Future that completes when shutdown is finished

Source

fn get_next_task(&mut self) -> Option<(ExecutionTask, TaskHandle)>

Get next task to execute (for scheduler implementations)

Source

fn mark_task_completed(&mut self, handle: &TaskHandle) -> SklResult<()>

Mark task as completed

Source

fn mark_task_failed( &mut self, handle: &TaskHandle, error: String, ) -> SklResult<()>

Mark task as failed

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§