pub struct CountedEvent<E> { /* private fields */ }Expand description
A CountedEvent wraps a type that implements the EventSetter trait. It can tell you how many waiters there are on that very event. The count will only go up once the waiter actually starts waiting on the event. If there is an immediate return on the first time the wait is polled, the count will not go up.
The count will go up if the first call to poll wait returns Poll::Pending, indicating that the waiter is actually waiting on notification. Upon notification, the count will be decremented.
§Cancel Safety
On Drop the count is decremented if the CountedAwaiter had already incremented the count and is not yet in the complete state.
Implementations§
Trait Implementations§
Source§impl<'a, E> EventSetter<'a> for CountedEvent<E>where
E: EventSetter<'a> + 'a,
impl<'a, E> EventSetter<'a> for CountedEvent<E>where
E: EventSetter<'a> + 'a,
Source§type Waiter = CountedAwaiter<'a, E, <E as EventSetter<'a>>::Waiter>
type Waiter = CountedAwaiter<'a, E, <E as EventSetter<'a>>::Waiter>
The future representing a pending acquisition of the event.
Source§fn new() -> Self
fn new() -> Self
Creates a new event in the unset state. This
is the expected mode of operation for most events,
and means that if a task begins waiting, they will
wait until the event is set.
Source§fn new_set() -> Self
fn new_set() -> Self
Creates an event in the set state. This means that the event
can be immediately acquired.
Source§fn wait(&'a self) -> CountedAwaiter<'a, E, E::Waiter> ⓘ
fn wait(&'a self) -> CountedAwaiter<'a, E, E::Waiter> ⓘ
Waits on the event. This returns a future which when polled
will wait for the event to be acquired.
Source§fn try_wait(&self) -> bool
fn try_wait(&self) -> bool
Will try to immediately acquire the event along the fast path. This
method is non-blocking and will return true if we could acquire the event,
and false if we cannot. This will clear the set flag.
Source§fn set_all<F: FnMut()>(&self, functor: F)
fn set_all<F: FnMut()>(&self, functor: F)
Sets the event and wakes up all events from the queue if they
are pending with the functor. This functor allows more advanced book-keeping
per event, for instance with counted events.
Source§fn set_one(&self) -> bool
fn set_one(&self) -> bool
Sets the event. This will wake up any events from the queue if
any are pending. This returns a boolean if we were able to actually
wake up an event or not.
Source§fn has_waiters(&self) -> bool
fn has_waiters(&self) -> bool
If the event has any pending waiters.
Auto Trait Implementations§
impl<E> !Freeze for CountedEvent<E>
impl<E> RefUnwindSafe for CountedEvent<E>where
E: RefUnwindSafe,
impl<E> Send for CountedEvent<E>where
E: Send,
impl<E> Sync for CountedEvent<E>where
E: Sync,
impl<E> Unpin for CountedEvent<E>where
E: Unpin,
impl<E> UnwindSafe for CountedEvent<E>where
E: UnwindSafe,
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