pub struct Waiter { /* private fields */ }Expand description
A waiter that can put the current thread to sleep until it is woken up by the associated
Waker.
By definition, a waiter belongs to the current thread, so it cannot be sent to another thread and its reference cannot be shared between threads.
Implementations§
Source§impl Waiter
impl Waiter
Sourcepub exec fn new_pair() -> ret : (Self, Arc<Waker>)
pub exec fn new_pair() -> ret : (Self, Arc<Waker>)
ret.0.rel_waker(ret.1),Creates a waiter and its associated Waker.
Sourcepub exec fn wait(&self)
pub exec fn wait(&self)
Waits until the waiter is woken up by calling Waker::wake_up on the associated
Waker.
This method returns immediately if the waiter has been woken since the end of the last call to this method (or since the waiter was created, if this method has not been called before). Otherwise, it puts the current thread to sleep until the waiter is woken up.
Sourcepub exec fn wait_until_or_cancelled<F, R, FCancel, E>(
&self,
cond: F,
cancel_cond: FCancel,
) -> ret : Result<R, E>
pub exec fn wait_until_or_cancelled<F, R, FCancel, E>( &self, cond: F, cancel_cond: FCancel, ) -> ret : Result<R, E>
cond.requires(()),cancel_cond.requires(()),ensuresmatch ret {
Ok(res) => cond.ensures((), Some(res)),
Err(e) => cancel_cond.ensures((), Err(e)),
},Waits until some condition is met or the cancel condition becomes true.
This method will return Ok(_) if the condition returns Some(_), and will stop waiting
if the cancel condition returns Err(_). In this situation, this method will return the Err(_)
generated by the cancel condition.