pub struct Pool<I, O>{ /* private fields */ }Expand description
A bounded async worker pool.
Implementations§
Source§impl<I, O> Pool<I, O>
impl<I, O> Pool<I, O>
Sourcepub fn new(handler: Arc<dyn Handler<I, O>>, config: PoolConfig) -> Self
pub fn new(handler: Arc<dyn Handler<I, O>>, config: PoolConfig) -> Self
Create a new pool backed by handler.
config.size is clamped to a minimum of 1 (a zero-sized pool can never execute tasks because no permits would be available);
a tracing warn is emitted when this clamp engages.
Sourcepub async fn submit(&self, input: I) -> AppResult<TaskHandle<O>>
pub async fn submit(&self, input: I) -> AppResult<TaskHandle<O>>
Submit a task; returns a TaskHandle immediately.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Number of permits currently available for task execution.
Trait Implementations§
Auto Trait Implementations§
impl<I, O> !RefUnwindSafe for Pool<I, O>
impl<I, O> !UnwindSafe for Pool<I, O>
impl<I, O> Freeze for Pool<I, O>
impl<I, O> Send for Pool<I, O>
impl<I, O> Sync for Pool<I, O>
impl<I, O> Unpin for Pool<I, O>
impl<I, O> UnsafeUnpin for Pool<I, O>
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