pub struct ConnectionCounter { /* private fields */ }Expand description
Connection counter for tracking active connections.
This is designed to be wrapped in Arc and shared across async tasks.
Use try_acquire_arc to get a guard that can be moved into spawned tasks.
Implementations§
Source§impl ConnectionCounter
impl ConnectionCounter
Sourcepub fn try_acquire_arc(self: &Arc<Self>) -> Option<ConnectionGuard>
pub fn try_acquire_arc(self: &Arc<Self>) -> Option<ConnectionGuard>
Try to acquire a connection slot (for use when counter is in Arc).
Returns a guard that releases the slot when dropped, or None if at capacity.
The guard is Send + 'static and can be moved into spawned async tasks.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ConnectionCounter
impl RefUnwindSafe for ConnectionCounter
impl Send for ConnectionCounter
impl Sync for ConnectionCounter
impl Unpin for ConnectionCounter
impl UnsafeUnpin for ConnectionCounter
impl UnwindSafe for ConnectionCounter
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