pub struct Semaphore {
pub max: usize,
/* private fields */
}
Expand description
A counter that has a maximum value
Fields§
§max: usize
Implementations§
Source§impl Semaphore
impl Semaphore
pub fn count(&self, ordering: Ordering) -> usize
pub fn new(max: usize) -> Self
pub fn at_max(&self, ordering: Ordering) -> bool
Sourcepub fn try_get(&self) -> Result<SemaphoreGuard<'_>, SemaphoreError>
pub fn try_get(&self) -> Result<SemaphoreGuard<'_>, SemaphoreError>
Try to increment the count and return a Guard
Never blocks
§Errors
Will error if the count is at max already
Auto Trait Implementations§
impl !Freeze for Semaphore
impl RefUnwindSafe for Semaphore
impl Send for Semaphore
impl Sync for Semaphore
impl Unpin for Semaphore
impl UnwindSafe for Semaphore
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