Skip to main content

SchedulerControl

Trait SchedulerControl 

Source
pub trait SchedulerControl {
    // Required methods
    fn pending_tasks(&self) -> usize;
    fn active_workers(&self) -> usize;
    fn worker_count(&self) -> usize;
    fn has_work(&self) -> bool;
    fn join(&self) -> ExecutorResult<()>;
    fn shutdown(&self);
    fn metrics(&self) -> ScheduleMetrics;
}
Expand description

Introspect and control a scheduler’s lifecycle.

Required Methods§

Source

fn pending_tasks(&self) -> usize

Number of queued-but-not-yet-running jobs.

Source

fn active_workers(&self) -> usize

Number of jobs currently executing.

Source

fn worker_count(&self) -> usize

Number of worker threads.

Source

fn has_work(&self) -> bool

Whether any work is queued or running.

Source

fn join(&self) -> ExecutorResult<()>

Block until the scheduler is quiescent (no queued or running work).

§Errors

Returns an ExecutorError if the scheduler cannot reach quiescence.

Source

fn shutdown(&self)

Drain queued work and stop the worker sets.

Exactly one non-worker caller joins the worker sets. Other external callers wait for that join. Scheduler workers close the blocking lane and return before the election; when no external caller remains, worker ownership releases the scheduler after every accepted task drains.

Source

fn metrics(&self) -> ScheduleMetrics

Snapshot the scheduler metrics.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<const BLOCKING_QUEUE_CAPACITY: usize, const SPIN_LIMIT: usize> SchedulerControl for ThreadScheduler<BLOCKING_QUEUE_CAPACITY, SPIN_LIMIT>