diff options
Diffstat (limited to 'embassy-sync/src/channel.rs')
| -rw-r--r-- | embassy-sync/src/channel.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index de437cc52..dbd24a6c7 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -50,8 +50,8 @@ use core::task::{Context, Poll}; | |||
| 50 | 50 | ||
| 51 | use heapless::Deque; | 51 | use heapless::Deque; |
| 52 | 52 | ||
| 53 | use crate::blocking_mutex::raw::RawMutex; | ||
| 54 | use crate::blocking_mutex::Mutex; | 53 | use crate::blocking_mutex::Mutex; |
| 54 | use crate::blocking_mutex::raw::RawMutex; | ||
| 55 | use crate::waitqueue::WakerRegistration; | 55 | use crate::waitqueue::WakerRegistration; |
| 56 | 56 | ||
| 57 | /// Send-only access to a [`Channel`]. | 57 | /// Send-only access to a [`Channel`]. |
| @@ -1112,11 +1112,13 @@ mod tests { | |||
| 1112 | static CHANNEL: StaticCell<Channel<CriticalSectionRawMutex, u32, 3>> = StaticCell::new(); | 1112 | static CHANNEL: StaticCell<Channel<CriticalSectionRawMutex, u32, 3>> = StaticCell::new(); |
| 1113 | let c = &*CHANNEL.init(Channel::new()); | 1113 | let c = &*CHANNEL.init(Channel::new()); |
| 1114 | let c2 = c; | 1114 | let c2 = c; |
| 1115 | assert!(executor | 1115 | assert!( |
| 1116 | .spawn(async move { | 1116 | executor |
| 1117 | assert!(c2.try_send(1).is_ok()); | 1117 | .spawn(async move { |
| 1118 | }) | 1118 | assert!(c2.try_send(1).is_ok()); |
| 1119 | .is_ok()); | 1119 | }) |
| 1120 | .is_ok() | ||
| 1121 | ); | ||
| 1120 | assert_eq!(c.receive().await, 1); | 1122 | assert_eq!(c.receive().await, 1); |
| 1121 | } | 1123 | } |
| 1122 | 1124 | ||
| @@ -1143,13 +1145,15 @@ mod tests { | |||
| 1143 | // However, I've used the debugger to observe that the send does indeed wait. | 1145 | // However, I've used the debugger to observe that the send does indeed wait. |
| 1144 | Delay::new(Duration::from_millis(500)).await; | 1146 | Delay::new(Duration::from_millis(500)).await; |
| 1145 | assert_eq!(c.receive().await, 1); | 1147 | assert_eq!(c.receive().await, 1); |
| 1146 | assert!(executor | 1148 | assert!( |
| 1147 | .spawn(async move { | 1149 | executor |
| 1148 | loop { | 1150 | .spawn(async move { |
| 1149 | c.receive().await; | 1151 | loop { |
| 1150 | } | 1152 | c.receive().await; |
| 1151 | }) | 1153 | } |
| 1152 | .is_ok()); | 1154 | }) |
| 1155 | .is_ok() | ||
| 1156 | ); | ||
| 1153 | send_task_1.unwrap().await; | 1157 | send_task_1.unwrap().await; |
| 1154 | send_task_2.unwrap().await; | 1158 | send_task_2.unwrap().await; |
| 1155 | } | 1159 | } |
