pub struct WorkerPool { /* private fields */ }Expand description
Executes tasks concurrently under a global concurrency limit.
Each task is run on its own Tokio task but must first acquire a permit from
a shared Semaphore, which caps how many run at once. The pool also owns
the retry loop, per-attempt timeout, and circuit-breaker gating so the
executor’s scheduling loop stays simple.
Implementations§
Source§impl WorkerPool
impl WorkerPool
Sourcepub fn new(
concurrency: usize,
retry: RetryPolicy,
timeout: Option<Duration>,
metrics: Arc<MetricsCollector>,
) -> Self
pub fn new( concurrency: usize, retry: RetryPolicy, timeout: Option<Duration>, metrics: Arc<MetricsCollector>, ) -> Self
Create a pool allowing concurrency simultaneous tasks.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Permits currently available (i.e. free concurrency slots).
Sourcepub fn spawn(
&self,
task: Arc<dyn Task>,
ctx: Arc<Context>,
breaker: Option<Arc<CircuitBreaker>>,
) -> JoinHandle<TaskResult>
pub fn spawn( &self, task: Arc<dyn Task>, ctx: Arc<Context>, breaker: Option<Arc<CircuitBreaker>>, ) -> JoinHandle<TaskResult>
Spawn task for execution, returning a handle to its eventual result.
breaker, if supplied, gates execution: when open, the task fails fast
with TaskError::CircuitOpen without consuming an attempt.
Auto 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