Struct waker_generic::Blocker
source · pub struct Blocker { /* private fields */ }
Expand description
A blocker that blocks in a loop until the associated waker is woken.
To obtain a Blocker
and its associated core::task::Waker
, call new_waker()
.
Implementations§
source§impl Blocker
impl Blocker
sourcepub fn block<B, R>(&self, block_action: B)where
B: Fn() -> R,
pub fn block<B, R>(&self, block_action: B)where B: Fn() -> R,
Performs the given block_action
within this Blocker
,
looping until the associated waker is woken.
If the waker was already woken prior to this function being called, it will return immediately.
After this function returns, the inner state of the blocker+waker pair will have been reset to its initial “unwoken” state, enabling them to be re-used. In other words, this function can be called again, at which point it will block until the waker is woken again.
Arguments
block_action
: a closure that is called in a loop until its woker is woken. The return valueR
of the closure is any arbitrary value that will be held until after the blocker has released the lock on its inner state shared with the waker.- This can be used, for example, to yield the CPU to another task.
Auto Trait Implementations§
impl !RefUnwindSafe for Blocker
impl Send for Blocker
impl Sync for Blocker
impl Unpin for Blocker
impl !UnwindSafe for Blocker
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