aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Kröger <[email protected]>2020-12-30 12:15:49 +0100
committerTimo Kröger <[email protected]>2020-12-30 19:24:12 +0100
commitc97d5262f56814639fa995c8426384efdf379c55 (patch)
tree944e11de17eeaa277d2bf5313c1e193810c87248
parent6bc1a712ffd88d16ba8900e83672394b5c20a1e5 (diff)
Blocking wait method for signals
-rw-r--r--embassy/src/util/signal.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/embassy/src/util/signal.rs b/embassy/src/util/signal.rs
index bde10c562..cb6410611 100644
--- a/embassy/src/util/signal.rs
+++ b/embassy/src/util/signal.rs
@@ -62,4 +62,13 @@ impl<T: Send> Signal<T> {
62 pub fn wait(&self) -> impl Future<Output = T> + '_ { 62 pub fn wait(&self) -> impl Future<Output = T> + '_ {
63 futures::future::poll_fn(move |cx| self.poll_wait(cx)) 63 futures::future::poll_fn(move |cx| self.poll_wait(cx))
64 } 64 }
65
66 /// Blocks until the signal has been received.
67 ///
68 /// Returns immediately when [`poll_wait()`] has not been called before.
69 pub fn blocking_wait(&self) {
70 while cortex_m::interrupt::free(|_| {
71 matches!(unsafe { &*self.state.get() }, State::Waiting(_))
72 }) {}
73 }
65} 74}