aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-sync/src')
-rw-r--r--embassy-sync/src/signal.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs
index 8cb832a2b..c3c10a8af 100644
--- a/embassy-sync/src/signal.rs
+++ b/embassy-sync/src/signal.rs
@@ -3,7 +3,7 @@ use core::cell::Cell;
3use core::future::{poll_fn, Future}; 3use core::future::{poll_fn, Future};
4use core::task::{Context, Poll, Waker}; 4use core::task::{Context, Poll, Waker};
5 5
6use crate::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex}; 6use crate::blocking_mutex::raw::RawMutex;
7use crate::blocking_mutex::Mutex; 7use crate::blocking_mutex::Mutex;
8 8
9/// Single-slot signaling primitive. 9/// Single-slot signaling primitive.
@@ -22,19 +22,20 @@ use crate::blocking_mutex::Mutex;
22/// 22///
23/// ``` 23/// ```
24/// use embassy_sync::signal::Signal; 24/// use embassy_sync::signal::Signal;
25/// use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
25/// 26///
26/// enum SomeCommand { 27/// enum SomeCommand {
27/// On, 28/// On,
28/// Off, 29/// Off,
29/// } 30/// }
30/// 31///
31/// static SOME_SIGNAL: Signal<SomeCommand> = Signal::new(); 32/// static SOME_SIGNAL: Signal<CriticalSectionRawMutex, SomeCommand> = Signal::new();
32/// ``` 33/// ```
33pub struct Signal<T, R = CriticalSectionRawMutex> 34pub struct Signal<M, T>
34where 35where
35 R: RawMutex, 36 M: RawMutex,
36{ 37{
37 state: Mutex<R, Cell<State<T>>>, 38 state: Mutex<M, Cell<State<T>>>,
38} 39}
39 40
40enum State<T> { 41enum State<T> {
@@ -43,9 +44,9 @@ enum State<T> {
43 Signaled(T), 44 Signaled(T),
44} 45}
45 46
46impl<T, R> Signal<T, R> 47impl<M, T> Signal<M, T>
47where 48where
48 R: RawMutex, 49 M: RawMutex,
49{ 50{
50 /// Create a new `Signal`. 51 /// Create a new `Signal`.
51 pub const fn new() -> Self { 52 pub const fn new() -> Self {
@@ -55,9 +56,9 @@ where
55 } 56 }
56} 57}
57 58
58impl<R, T: Send> Signal<T, R> 59impl<M, T: Send> Signal<M, T>
59where 60where
60 R: RawMutex, 61 M: RawMutex,
61{ 62{
62 /// Mark this Signal as signaled. 63 /// Mark this Signal as signaled.
63 pub fn signal(&self, val: T) { 64 pub fn signal(&self, val: T) {