pub struct SemaphorePermit<'a> { /* private fields */ }Expand description
Permits taken from a Semaphore, returned when dropped.
The release is one atomic read-modify-write when no waiter needs telling. Otherwise it is lock-free, not wait-free: it returns after one pass over the queue, plus at most one for each operation of another thread that lands on the queue meanwhile (see Progress).
Implementations§
Source§impl<'a> SemaphorePermit<'a>
impl<'a> SemaphorePermit<'a>
Sourcepub fn merge(&mut self, other: Self)
pub fn merge(&mut self, other: Self)
Merges other into this permit, so one drop returns both.
§Panics
When the permits come from different semaphores, or their total
overflows usize.
Sourcepub fn split(&mut self, n: usize) -> Option<Self>
pub fn split(&mut self, n: usize) -> Option<Self>
Splits n permits off this one, or returns None when it holds
fewer than n.
Sourcepub fn num_permits(&self) -> usize
pub fn num_permits(&self) -> usize
How many permits this holds.
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
How many permits this holds; the same as
num_permits.
Trait Implementations§
Source§impl Debug for SemaphorePermit<'_>
impl Debug for SemaphorePermit<'_>
Source§impl Drop for SemaphorePermit<'_>
impl Drop for SemaphorePermit<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SemaphorePermit<'a>
impl<'a> !UnwindSafe for SemaphorePermit<'a>
impl<'a> Freeze for SemaphorePermit<'a>
impl<'a> Send for SemaphorePermit<'a>
impl<'a> Sync for SemaphorePermit<'a>
impl<'a> Unpin for SemaphorePermit<'a>
impl<'a> UnsafeUnpin for SemaphorePermit<'a>
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