pub struct WorkerPool { /* private fields */ }Expand description
Pool managing active workers
Implementations§
Source§impl WorkerPool
impl WorkerPool
Sourcepub fn new(max_workers: usize) -> Self
pub fn new(max_workers: usize) -> Self
Creates a new worker pool with the specified maximum number of workers.
§Arguments
max_workers- The maximum number of concurrent workers allowed
Sourcepub async fn execute(
&self,
task: Box<dyn Task + Send + Sync>,
) -> Result<TaskResult, String>
pub async fn execute( &self, task: Box<dyn Task + Send + Sync>, ) -> 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§
Auto Trait Implementations§
impl Freeze for WorkerPool
impl RefUnwindSafe for WorkerPool
impl Send for WorkerPool
impl Sync for WorkerPool
impl Unpin for WorkerPool
impl UnwindSafe 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