pub struct DelayedTaskSchedulerInner {
pub state: Monitor<DelayedTaskSchedulerState>,
pub queued_task_count: AtomicUsize,
pub running_task_count: AtomicUsize,
pub completed_task_count: AtomicUsize,
pub cancelled_task_count: AtomicUsize,
}Expand description
Shared delayed scheduler state.
Fields§
§state: Monitor<DelayedTaskSchedulerState>Mutable lifecycle and heap state.
queued_task_count: AtomicUsizeNumber of tasks still pending in the delay heap.
running_task_count: AtomicUsizeNumber of tasks currently executing on the scheduler thread.
completed_task_count: AtomicUsizeNumber of tasks that ran to completion.
cancelled_task_count: AtomicUsizeNumber of delayed tasks cancelled before execution.
Implementations§
Source§impl DelayedTaskSchedulerInner
impl DelayedTaskSchedulerInner
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty delayed scheduler.
§Returns
Shared scheduler state before its worker thread starts.
Sourcepub fn queued_count(&self) -> usize
pub fn queued_count(&self) -> usize
Returns the queued delayed task count.
§Returns
Number of tasks that have not started or been cancelled.
Sourcepub fn running_count(&self) -> usize
pub fn running_count(&self) -> usize
Returns the currently running task count.
§Returns
1 when the scheduler thread is running a task, otherwise 0.
Sourcepub fn finish_queued_cancellation(&self)
pub fn finish_queued_cancellation(&self)
Records a pending task cancellation.
Sourcepub fn cancel_task_state(&self, task_state: &AtomicU8) -> bool
pub fn cancel_task_state(&self, task_state: &AtomicU8) -> bool
Sourcepub fn start_task_state(&self, task_state: &AtomicU8) -> bool
pub fn start_task_state(&self, task_state: &AtomicU8) -> bool
Sourcepub fn stop(&self) -> StopReport
pub fn stop(&self) -> StopReport
Requests immediate shutdown and cancels all queued delayed tasks.
§Returns
Count-based shutdown report.
Sourcepub fn is_not_running(&self) -> bool
pub fn is_not_running(&self) -> bool
Sourcepub fn lifecycle(&self) -> ExecutorServiceLifecycle
pub fn lifecycle(&self) -> ExecutorServiceLifecycle
Returns the current lifecycle state.
§Returns
ExecutorServiceLifecycle::Terminated after the worker has exited,
otherwise the stored lifecycle state.
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns whether the scheduler thread has exited.
§Returns
true after shutdown and scheduler termination.
Sourcepub fn wait_for_termination(&self)
pub fn wait_for_termination(&self)
Waits until the scheduler thread exits.
Sourcepub fn terminate(&self, state: &mut DelayedTaskSchedulerState)
pub fn terminate(&self, state: &mut DelayedTaskSchedulerState)
Marks the scheduler thread as terminated.