pub struct Listener { /* private fields */ }Expand description
A struct used to wait for a trigger event from a Trigger.
Can be waited on synchronously via Listener::wait or asynchronously thanks to the struct
implementing Future.
The listener can be cloned and any amount of threads and tasks can wait for the same trigger at the same time.
Implementations§
Source§impl Listener
impl Listener
Sourcepub fn wait(&self)
pub fn wait(&self)
Wait for this trigger synchronously.
Blocks the current thread until the corresponding Trigger is triggered.
If the trigger has already been triggered at least once, this returns immediately.
Sourcepub fn wait_timeout(&self, duration: Duration) -> bool
pub fn wait_timeout(&self, duration: Duration) -> bool
Wait for this trigger synchronously, timing out after a specified duration.
The semantics of this function are equivalent to Listener::wait except that the
thread will be blocked for roughly no longer than duration.
Returns true if this method returned because the trigger was triggered. Returns
false if it returned due to the timeout.
In an async program the same can be achieved by wrapping the Listener in one of the
many Timeout implementations that exists.
Sourcepub fn is_triggered(&self) -> bool
pub fn is_triggered(&self) -> bool
Returns true if this trigger has been triggered.
Trait Implementations§
impl Unpin for Listener
Auto Trait Implementations§
impl Freeze for Listener
impl RefUnwindSafe for Listener
impl Send for Listener
impl Sync for Listener
impl UnwindSafe for Listener
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more