aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Mabin <[email protected]>2023-11-18 15:08:16 +0000
committerScott Mabin <[email protected]>2023-11-18 15:09:41 +0000
commit5a60024af71b70c059d4a2a2eacdfd7f73a3398d (patch)
tree2098f3f03c350507c0fd354d3f3ce354a86bdcc8
parentf482a105b8491f3c21d41cb7e6f52fe6d778258f (diff)
docs
-rw-r--r--embassy-sync/README.md1
-rw-r--r--embassy-sync/src/channel/priority.rs6
2 files changed, 6 insertions, 1 deletions
diff --git a/embassy-sync/README.md b/embassy-sync/README.md
index cc65cf6ef..55618f72d 100644
--- a/embassy-sync/README.md
+++ b/embassy-sync/README.md
@@ -5,6 +5,7 @@ An [Embassy](https://embassy.dev) project.
5Synchronization primitives and data structures with async support: 5Synchronization primitives and data structures with async support:
6 6
7- [`Channel`](channel::Channel) - A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer. 7- [`Channel`](channel::Channel) - A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer.
8- [`PriorityChannel`](channel::priority::PriorityChannel) - A Multiple Producer Multiple Consumer (MPMC) channel. Each message is only received by a single consumer. Higher priority items are sifted to the front of the channel.
8- [`PubSubChannel`](pubsub::PubSubChannel) - A broadcast channel (publish-subscribe) channel. Each message is received by all consumers. 9- [`PubSubChannel`](pubsub::PubSubChannel) - A broadcast channel (publish-subscribe) channel. Each message is received by all consumers.
9- [`Signal`](signal::Signal) - Signalling latest value to a single consumer. 10- [`Signal`](signal::Signal) - Signalling latest value to a single consumer.
10- [`Mutex`](mutex::Mutex) - Mutex for synchronizing state between asynchronous tasks. 11- [`Mutex`](mutex::Mutex) - Mutex for synchronizing state between asynchronous tasks.
diff --git a/embassy-sync/src/channel/priority.rs b/embassy-sync/src/channel/priority.rs
index 1fd137db5..61dc7be68 100644
--- a/embassy-sync/src/channel/priority.rs
+++ b/embassy-sync/src/channel/priority.rs
@@ -323,7 +323,9 @@ where
323/// buffer is full, attempts to `send` new messages will wait until a message is 323/// buffer is full, attempts to `send` new messages will wait until a message is
324/// received from the channel. 324/// received from the channel.
325/// 325///
326/// All data sent will become available in the same order as it was sent. 326/// Sent data may be reordered based on their priorty within the channel.
327/// For example, in a [`Max`](heapless::binary_heap::Max) [`PriorityChannel`]
328/// containing `u32`'s, data sent in the following order `[1, 2, 3]` will be recieved as `[3, 2, 1]`.
327pub struct PriorityChannel<M, T, K, const N: usize> 329pub struct PriorityChannel<M, T, K, const N: usize>
328where 330where
329 T: Ord, 331 T: Ord,
@@ -509,8 +511,10 @@ mod tests {
509 // Prio channel with kind `Max` sifts larger numbers to the front of the queue 511 // Prio channel with kind `Max` sifts larger numbers to the front of the queue
510 let mut c = ChannelState::<u32, Max, 3>::new(); 512 let mut c = ChannelState::<u32, Max, 3>::new();
511 assert!(c.try_send(1).is_ok()); 513 assert!(c.try_send(1).is_ok());
514 assert!(c.try_send(2).is_ok());
512 assert!(c.try_send(3).is_ok()); 515 assert!(c.try_send(3).is_ok());
513 assert_eq!(c.try_receive().unwrap(), 3); 516 assert_eq!(c.try_receive().unwrap(), 3);
517 assert_eq!(c.try_receive().unwrap(), 2);
514 assert_eq!(c.try_receive().unwrap(), 1); 518 assert_eq!(c.try_receive().unwrap(), 1);
515 } 519 }
516 520