Skip to main content

ClassifiedWorker

Trait ClassifiedWorker 

Source
pub trait ClassifiedWorker<C: WorkerClassification>: Send + 'static {
    // Required methods
    fn is_work(&self) -> bool;
    fn is_valid(&self, c: C) -> bool;
    fn classification(&self) -> C;
}
Expand description

A classification-aware worker managed by ClassifiedWorkerPool.

Methods on this trait may be called while the pool’s internal state lock is held. Implementations must be non-blocking and must not re-enter APIs on the same pool.

Required Methods§

Source

fn is_work(&self) -> bool

Source

fn is_valid(&self, c: C) -> bool

Returns whether this worker can currently serve the requested classification. The pool still tracks capacity by the worker’s primary classification(). A worker that is no longer valid for its cached primary classification is discarded.

Source

fn classification(&self) -> C

Returns the worker’s primary classification used for accounting and replacement. The pool validates and caches this value when the worker is created. If it differs from the cached value when the worker is returned, the worker is discarded.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§