diff options
Diffstat (limited to 'embassy-sync/src/waitqueue/multi_waker.rs')
| -rw-r--r-- | embassy-sync/src/waitqueue/multi_waker.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/embassy-sync/src/waitqueue/multi_waker.rs b/embassy-sync/src/waitqueue/multi_waker.rs index 0e520bf40..56c0cd1b2 100644 --- a/embassy-sync/src/waitqueue/multi_waker.rs +++ b/embassy-sync/src/waitqueue/multi_waker.rs | |||
| @@ -3,6 +3,9 @@ use core::task::Waker; | |||
| 3 | use heapless::Vec; | 3 | use heapless::Vec; |
| 4 | 4 | ||
| 5 | /// Utility struct to register and wake multiple wakers. | 5 | /// Utility struct to register and wake multiple wakers. |
| 6 | /// Queue of wakers with a maximum length of `N`. | ||
| 7 | /// Intended for waking multiple tasks. | ||
| 8 | #[derive(Debug)] | ||
| 6 | pub struct MultiWakerRegistration<const N: usize> { | 9 | pub struct MultiWakerRegistration<const N: usize> { |
| 7 | wakers: Vec<Waker, N>, | 10 | wakers: Vec<Waker, N>, |
| 8 | } | 11 | } |
| @@ -13,7 +16,9 @@ impl<const N: usize> MultiWakerRegistration<N> { | |||
| 13 | Self { wakers: Vec::new() } | 16 | Self { wakers: Vec::new() } |
| 14 | } | 17 | } |
| 15 | 18 | ||
| 16 | /// Register a waker. If the buffer is full the function returns it in the error | 19 | /// Register a waker. |
| 20 | /// | ||
| 21 | /// If the buffer is full, [wakes all the wakers](Self::wake), clears its buffer and registers the waker. | ||
| 17 | pub fn register(&mut self, w: &Waker) { | 22 | pub fn register(&mut self, w: &Waker) { |
| 18 | // If we already have some waker that wakes the same task as `w`, do nothing. | 23 | // If we already have some waker that wakes the same task as `w`, do nothing. |
| 19 | // This avoids cloning wakers, and avoids unnecessary mass-wakes. | 24 | // This avoids cloning wakers, and avoids unnecessary mass-wakes. |
