pub struct Barrier { /* private fields */ }Expand description
A barrier that releases its waiters in groups of n.
The n-th wait of a generation completes at once as
its leader and wakes the other n - 1; the barrier then starts the
next generation. A wait dropped before its generation completes stays
counted: the generation completes once n parties have arrived, and
the dropped one is simply not woken. (Taking the arrival back would
race with the arrival that completes the generation.)
use nuclei::sync::Barrier;
use std::future::Future;
use std::pin::pin;
use std::task::{Context, Waker};
let barrier = Barrier::new(2);
let mut cx = Context::from_waker(Waker::noop());
let mut first = pin!(barrier.wait());
assert!(first.as_mut().poll(&mut cx).is_pending());
let mut second = pin!(barrier.wait());
assert!(second.as_mut().poll(&mut cx).is_ready());
assert!(first.poll(&mut cx).is_ready());Implementations§
Trait Implementations§
impl Send for Barrier
impl Sync for Barrier
Auto Trait Implementations§
impl !Freeze for Barrier
impl !RefUnwindSafe for Barrier
impl !UnwindSafe for Barrier
impl Unpin for Barrier
impl UnsafeUnpin for Barrier
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