pub struct Latch { /* private fields */ }Expand description
A latch that opens when its count reaches zero, and stays open.
use nuclei::sync::Latch;
let done = Latch::new(2);
done.count_down();
assert!(!done.is_set());
done.count_down();
assert!(done.is_set());Implementations§
Source§impl Latch
impl Latch
Sourcepub const fn new(count: usize) -> Self
pub const fn new(count: usize) -> Self
A latch that opens after count calls to
count_down; open at once when count is
zero.
Sourcepub fn count_down(&self)
pub fn count_down(&self)
Lowers the count by one, opening the latch when it reaches zero. Does nothing once the latch is open.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Latch
impl !RefUnwindSafe for Latch
impl !UnwindSafe for Latch
impl Send for Latch
impl Sync for Latch
impl Unpin for Latch
impl UnsafeUnpin for Latch
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