pub struct WorkerPool { /* private fields */ }Expand description
Pool managing active workers
Implementations§
Source§impl WorkerPool
impl WorkerPool
Sourcepub fn new(max_workers: usize) -> WorkerPool
pub fn new(max_workers: usize) -> WorkerPool
Creates a new worker pool with the specified maximum number of workers.
The pool reports through a crate::core::report::NoopReporter
unless a reporter is attached with WorkerPool::with_reporter.
§Arguments
max_workers- The maximum number of concurrent workers allowed
Sourcepub fn with_reporter(self, reporter: Arc<dyn Reporter>) -> WorkerPool
pub fn with_reporter(self, reporter: Arc<dyn Reporter>) -> WorkerPool
Attach a reporting sink, consuming and returning the pool.
§Arguments
reporter- Sink for progress chatter emitted while the pool drains its workers.
Sourcepub async fn execute(
&self,
task: Box<dyn Task + Sync + Send>,
) -> Result<TaskResult, String>
pub async fn execute( &self, task: Box<dyn Task + Sync + Send>, ) -> Result<TaskResult, String>
Execute a task by spawning a worker
Sourcepub fn get_active_count(&self) -> usize
pub fn get_active_count(&self) -> usize
Number of active workers
Sourcepub fn get_capacity(&self) -> usize
pub fn get_capacity(&self) -> usize
Maximum capacity of worker pool
Sourcepub fn get_worker_stats(&self) -> WorkerStats
pub fn get_worker_stats(&self) -> WorkerStats
Statistics about current workers
Sourcepub fn list_active_workers(&self) -> Vec<ActiveWorkerInfo>
pub fn list_active_workers(&self) -> Vec<ActiveWorkerInfo>
List active worker infos
Trait Implementations§
Source§impl Clone for WorkerPool
impl Clone for WorkerPool
Source§fn clone(&self) -> WorkerPool
fn clone(&self) -> WorkerPool
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WorkerPool
impl !UnwindSafe for WorkerPool
impl Freeze for WorkerPool
impl Send for WorkerPool
impl Sync for WorkerPool
impl Unpin for WorkerPool
impl UnsafeUnpin for WorkerPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more