diff options
Diffstat (limited to 'embassy-sync/src/channel/priority.rs')
| -rw-r--r-- | embassy-sync/src/channel/priority.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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]`. | ||
| 327 | pub struct PriorityChannel<M, T, K, const N: usize> | 329 | pub struct PriorityChannel<M, T, K, const N: usize> |
| 328 | where | 330 | where |
| 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 | ||
