aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-sync/src/priority_channel.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/embassy-sync/src/priority_channel.rs b/embassy-sync/src/priority_channel.rs
index 13c407c21..6f419aa6e 100644
--- a/embassy-sync/src/priority_channel.rs
+++ b/embassy-sync/src/priority_channel.rs
@@ -1,6 +1,7 @@
1//! A queue for sending values between asynchronous tasks. 1//! A queue for sending values between asynchronous tasks.
2//! 2//!
3//! Similar to a [`Channel`](crate::channel::Channel), however [`PriorityChannel`] sifts higher priority items to the front of the queue. 3//! Similar to a [`Channel`](crate::channel::Channel), however [`PriorityChannel`] sifts higher priority items to the front of the queue.
4//! Priority is determined by the `Ord` trait. Priority behavior is determined by the [`Kind`](heapless::binary_heap::Kind) parameter of the channel.
4 5
5use core::cell::RefCell; 6use core::cell::RefCell;
6use core::future::Future; 7use core::future::Future;
@@ -629,6 +630,16 @@ mod tests {
629 } 630 }
630 631
631 #[test] 632 #[test]
633 fn send_priority() {
634 // Prio channel with kind `Max` sifts larger numbers to the front of the queue
635 let mut c = ChannelState::<u32, Max, 3>::new();
636 assert!(c.try_send(1).is_ok());
637 assert!(c.try_send(3).is_ok());
638 assert_eq!(c.try_receive().unwrap(), 3);
639 assert_eq!(c.try_receive().unwrap(), 1);
640 }
641
642 #[test]
632 fn receiving_once_with_one_send() { 643 fn receiving_once_with_one_send() {
633 let mut c = ChannelState::<u32, Max, 3>::new(); 644 let mut c = ChannelState::<u32, Max, 3>::new();
634 assert!(c.try_send(1).is_ok()); 645 assert!(c.try_send(1).is_ok());