pub struct LockFreeTaskScheduler { /* private fields */ }Expand description
Lock-free task scheduler with work-stealing queues
Implementations§
Source§impl LockFreeTaskScheduler
impl LockFreeTaskScheduler
Sourcepub fn new(num_workers: usize, local_queue_capacity: usize) -> Self
pub fn new(num_workers: usize, local_queue_capacity: usize) -> Self
Create a new lock-free task scheduler
Sourcepub fn submit_task<F>(
&self,
config: TaskConfig,
task: F,
) -> Result<Receiver<TaskResult<()>>>
pub fn submit_task<F>( &self, config: TaskConfig, task: F, ) -> Result<Receiver<TaskResult<()>>>
Submit a task for execution
Sourcepub fn submit_batch<F>(
&self,
tasks: Vec<(TaskConfig, F)>,
) -> Result<Vec<Receiver<TaskResult<()>>>>
pub fn submit_batch<F>( &self, tasks: Vec<(TaskConfig, F)>, ) -> Result<Vec<Receiver<TaskResult<()>>>>
Submit multiple tasks in batch
Sourcepub fn steal_task(&self, worker_id: usize) -> Option<ScheduledTask>
pub fn steal_task(&self, worker_id: usize) -> Option<ScheduledTask>
Try to steal a task from queues (used by workers)
Sourcepub fn mark_task_completed(
&self,
worker_id: usize,
_task_id: &str,
duration: Duration,
)
pub fn mark_task_completed( &self, worker_id: usize, _task_id: &str, duration: Duration, )
Mark a task as completed
Sourcepub fn mark_task_failed(&self, worker_id: usize, _task_id: &str)
pub fn mark_task_failed(&self, worker_id: usize, _task_id: &str)
Mark a task as failed
Sourcepub fn get_stats(&self) -> SchedulerStats
pub fn get_stats(&self) -> SchedulerStats
Get current scheduler statistics
Sourcepub fn get_worker_state(&self, worker_id: usize) -> Option<WorkerState>
pub fn get_worker_state(&self, worker_id: usize) -> Option<WorkerState>
Get worker state
Sourcepub fn get_all_worker_states(&self) -> Vec<(usize, WorkerState)>
pub fn get_all_worker_states(&self) -> Vec<(usize, WorkerState)>
Get all worker states
Sourcepub fn has_pending_tasks(&self) -> bool
pub fn has_pending_tasks(&self) -> bool
Check if scheduler has pending tasks
Sourcepub fn pending_task_count(&self) -> usize
pub fn pending_task_count(&self) -> usize
Get the number of pending tasks
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset all statistics
Sourcepub async fn shutdown(&self, timeout: Duration) -> Result<()>
pub async fn shutdown(&self, timeout: Duration) -> Result<()>
Shutdown the scheduler gracefully
Sourcepub fn get_queue_lengths(&self) -> Vec<usize>
pub fn get_queue_lengths(&self) -> Vec<usize>
Get queue lengths for monitoring
Sourcepub fn get_load_balance_metrics(&self) -> LoadBalanceMetrics
pub fn get_load_balance_metrics(&self) -> LoadBalanceMetrics
Get load balancing metrics
Sourcepub fn get_local_queue_capacity(&self) -> usize
pub fn get_local_queue_capacity(&self) -> usize
Get the local queue capacity
Auto Trait Implementations§
impl !Freeze for LockFreeTaskScheduler
impl !RefUnwindSafe for LockFreeTaskScheduler
impl Send for LockFreeTaskScheduler
impl Sync for LockFreeTaskScheduler
impl Unpin for LockFreeTaskScheduler
impl UnwindSafe for LockFreeTaskScheduler
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more