Blocking wait method for signals
This commit is contained in:
parent
6bc1a712ff
commit
c97d5262f5
@ -62,4 +62,13 @@ impl<T: Send> Signal<T> {
|
|||||||
pub fn wait(&self) -> impl Future<Output = T> + '_ {
|
pub fn wait(&self) -> impl Future<Output = T> + '_ {
|
||||||
futures::future::poll_fn(move |cx| self.poll_wait(cx))
|
futures::future::poll_fn(move |cx| self.poll_wait(cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Blocks until the signal has been received.
|
||||||
|
///
|
||||||
|
/// Returns immediately when [`poll_wait()`] has not been called before.
|
||||||
|
pub fn blocking_wait(&self) {
|
||||||
|
while cortex_m::interrupt::free(|_| {
|
||||||
|
matches!(unsafe { &*self.state.get() }, State::Waiting(_))
|
||||||
|
}) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user