Skip to main content

WorkerPool

Trait WorkerPool 

Source
pub trait WorkerPool: Send + Sync {
    // Required methods
    fn acquire(&self, resource_tag: Option<&str>) -> bool;
    fn release(&self, resource_tag: Option<&str>);

    // Provided methods
    fn add_resource(&self, _tag: &str) { ... }
    fn remove_resource(&self, _tag: &str) { ... }
}
Expand description

Trait for managing available execution slots.

The executor calls acquire before dispatching a task and release when the task completes.

Required Methods§

Source

fn acquire(&self, resource_tag: Option<&str>) -> bool

Try to acquire a slot for a task. Returns true if available.

Source

fn release(&self, resource_tag: Option<&str>)

Release a slot after task completion.

Provided Methods§

Source

fn add_resource(&self, _tag: &str)

Add a resource to the pool (for dynamic pools).

Source

fn remove_resource(&self, _tag: &str)

Remove a resource from the pool (for dynamic pools).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§