aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src/channel.rs
diff options
context:
space:
mode:
authorMatteo Meluzzi <[email protected]>2025-10-24 15:48:34 +0200
committerMatteo Meluzzi <[email protected]>2025-10-24 15:48:34 +0200
commit7976f950b0de72c521f92efa350c67ccd197fab9 (patch)
tree8759312eb000de09b92a4921f476d5c16b7e7342 /embassy-sync/src/channel.rs
parent828a8df18d04877df1f55f04354980b28ff2f2f8 (diff)
Merge branch 'main' into 17-add-support-for-boot-protocol
Diffstat (limited to 'embassy-sync/src/channel.rs')
-rw-r--r--embassy-sync/src/channel.rs30
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
51use heapless::Deque; 51use heapless::Deque;
52 52
53use crate::blocking_mutex::raw::RawMutex;
54use crate::blocking_mutex::Mutex; 53use crate::blocking_mutex::Mutex;
54use crate::blocking_mutex::raw::RawMutex;
55use crate::waitqueue::WakerRegistration; 55use 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 }