diff options
Diffstat (limited to 'embassy-sync/src/priority_channel.rs')
| -rw-r--r-- | embassy-sync/src/priority_channel.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/embassy-sync/src/priority_channel.rs b/embassy-sync/src/priority_channel.rs index 715a20e86..1af7d9221 100644 --- a/embassy-sync/src/priority_channel.rs +++ b/embassy-sync/src/priority_channel.rs | |||
| @@ -8,11 +8,11 @@ use core::future::Future; | |||
| 8 | use core::pin::Pin; | 8 | use core::pin::Pin; |
| 9 | use core::task::{Context, Poll}; | 9 | use core::task::{Context, Poll}; |
| 10 | 10 | ||
| 11 | pub use heapless::binary_heap::{Kind, Max, Min}; | ||
| 12 | use heapless::BinaryHeap; | 11 | use heapless::BinaryHeap; |
| 12 | pub use heapless::binary_heap::{Kind, Max, Min}; | ||
| 13 | 13 | ||
| 14 | use crate::blocking_mutex::raw::RawMutex; | ||
| 15 | use crate::blocking_mutex::Mutex; | 14 | use crate::blocking_mutex::Mutex; |
| 15 | use crate::blocking_mutex::raw::RawMutex; | ||
| 16 | use crate::channel::{DynamicChannel, DynamicReceiver, DynamicSender, TryReceiveError, TrySendError}; | 16 | use crate::channel::{DynamicChannel, DynamicReceiver, DynamicSender, TryReceiveError, TrySendError}; |
| 17 | use crate::waitqueue::WakerRegistration; | 17 | use crate::waitqueue::WakerRegistration; |
| 18 | 18 | ||
| @@ -799,11 +799,13 @@ mod tests { | |||
| 799 | static CHANNEL: StaticCell<PriorityChannel<CriticalSectionRawMutex, u32, Max, 3>> = StaticCell::new(); | 799 | static CHANNEL: StaticCell<PriorityChannel<CriticalSectionRawMutex, u32, Max, 3>> = StaticCell::new(); |
| 800 | let c = &*CHANNEL.init(PriorityChannel::new()); | 800 | let c = &*CHANNEL.init(PriorityChannel::new()); |
| 801 | let c2 = c; | 801 | let c2 = c; |
| 802 | assert!(executor | 802 | assert!( |
| 803 | .spawn(async move { | 803 | executor |
| 804 | assert!(c2.try_send(1).is_ok()); | 804 | .spawn(async move { |
| 805 | }) | 805 | assert!(c2.try_send(1).is_ok()); |
| 806 | .is_ok()); | 806 | }) |
| 807 | .is_ok() | ||
| 808 | ); | ||
| 807 | assert_eq!(c.receive().await, 1); | 809 | assert_eq!(c.receive().await, 1); |
| 808 | } | 810 | } |
| 809 | 811 | ||
| @@ -830,13 +832,15 @@ mod tests { | |||
| 830 | // However, I've used the debugger to observe that the send does indeed wait. | 832 | // However, I've used the debugger to observe that the send does indeed wait. |
| 831 | Delay::new(Duration::from_millis(500)).await; | 833 | Delay::new(Duration::from_millis(500)).await; |
| 832 | assert_eq!(c.receive().await, 1); | 834 | assert_eq!(c.receive().await, 1); |
| 833 | assert!(executor | 835 | assert!( |
| 834 | .spawn(async move { | 836 | executor |
| 835 | loop { | 837 | .spawn(async move { |
| 836 | c.receive().await; | 838 | loop { |
| 837 | } | 839 | c.receive().await; |
| 838 | }) | 840 | } |
| 839 | .is_ok()); | 841 | }) |
| 842 | .is_ok() | ||
| 843 | ); | ||
| 840 | send_task_1.unwrap().await; | 844 | send_task_1.unwrap().await; |
| 841 | send_task_2.unwrap().await; | 845 | send_task_2.unwrap().await; |
| 842 | } | 846 | } |
