pub struct Bulkhead { /* private fields */ }Expand description
A concurrency cap.
Implementations§
Source§impl Bulkhead
impl Bulkhead
Sourcepub async fn acquire(&self) -> Result<BulkheadPermit, ToolkitError>
pub async fn acquire(&self) -> Result<BulkheadPermit, ToolkitError>
Wait until a slot is free, then take it.
Sourcepub fn try_acquire(&self) -> Option<BulkheadPermit>
pub fn try_acquire(&self) -> Option<BulkheadPermit>
Try to take a slot without waiting. Returns None if all slots are busy.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Number of currently free slots.
Sourcepub fn close(&self)
pub fn close(&self)
Close the bulkhead — pending acquires will return ToolkitError::BulkheadClosed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bulkhead
impl RefUnwindSafe for Bulkhead
impl Send for Bulkhead
impl Sync for Bulkhead
impl Unpin for Bulkhead
impl UnsafeUnpin for Bulkhead
impl UnwindSafe for Bulkhead
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