diff options
| author | ivmarkov <[email protected]> | 2022-09-24 12:08:46 +0300 |
|---|---|---|
| committer | ivmarkov <[email protected]> | 2022-09-25 09:40:36 +0300 |
| commit | c5ce02b30e488aade19f9f859425aa127d085b92 (patch) | |
| tree | d5795a6d01b6125c50a6010a850f4c0a8da55040 /embassy-sync | |
| parent | 85366661489c09fa8dec1375e9b9beee522e5e9f (diff) | |
Remove default, reorder generic params
Diffstat (limited to 'embassy-sync')
| -rw-r--r-- | embassy-sync/src/signal.rs | 19 |
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; | |||
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{poll_fn, Future}; |
| 4 | use core::task::{Context, Poll, Waker}; | 4 | use core::task::{Context, Poll, Waker}; |
| 5 | 5 | ||
| 6 | use crate::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex}; | 6 | use crate::blocking_mutex::raw::RawMutex; |
| 7 | use crate::blocking_mutex::Mutex; | 7 | use 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 | /// ``` |
| 33 | pub struct Signal<T, R = CriticalSectionRawMutex> | 34 | pub struct Signal<M, T> |
| 34 | where | 35 | where |
| 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 | ||
| 40 | enum State<T> { | 41 | enum State<T> { |
| @@ -43,9 +44,9 @@ enum State<T> { | |||
| 43 | Signaled(T), | 44 | Signaled(T), |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | impl<T, R> Signal<T, R> | 47 | impl<M, T> Signal<M, T> |
| 47 | where | 48 | where |
| 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 | ||
| 58 | impl<R, T: Send> Signal<T, R> | 59 | impl<M, T: Send> Signal<M, T> |
| 59 | where | 60 | where |
| 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) { |
