diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs index bea67d8be..97d76b463 100644 --- a/embassy-sync/src/signal.rs +++ b/embassy-sync/src/signal.rs @@ -111,6 +111,17 @@ where poll_fn(move |cx| self.poll_wait(cx)) } + /// non-blocking method to try and take the signal value. + pub fn try_take(&self) -> Option { + self.state.lock(|cell| { + let state = cell.replace(State::None); + match state { + State::Signaled(res) => Some(res), + _ => None, + } + }) + } + /// non-blocking method to check whether this signal has been signaled. pub fn signaled(&self) -> bool { self.state.lock(|cell| {