diff options
Diffstat (limited to 'embassy-sync/src')
| -rw-r--r-- | embassy-sync/src/blocking_mutex/mod.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/blocking_mutex/raw.rs | 2 | ||||
| -rw-r--r-- | embassy-sync/src/channel.rs | 7 | ||||
| -rw-r--r-- | embassy-sync/src/lazy_lock.rs | 2 | ||||
| -rw-r--r-- | embassy-sync/src/mutex.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/once_lock.rs | 10 | ||||
| -rw-r--r-- | embassy-sync/src/pipe.rs | 8 | ||||
| -rw-r--r-- | embassy-sync/src/pubsub/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-sync/src/pubsub/publisher.rs | 6 | ||||
| -rw-r--r-- | embassy-sync/src/pubsub/subscriber.rs | 3 | ||||
| -rw-r--r-- | embassy-sync/src/ring_buffer.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/rwlock.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/semaphore.rs | 6 | ||||
| -rw-r--r-- | embassy-sync/src/signal.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/waitqueue/atomic_waker_turbo.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/waitqueue/multi_waker.rs | 1 | ||||
| -rw-r--r-- | embassy-sync/src/watch.rs | 6 | ||||
| -rw-r--r-- | embassy-sync/src/zerocopy_channel.rs | 5 |
18 files changed, 64 insertions, 0 deletions
diff --git a/embassy-sync/src/blocking_mutex/mod.rs b/embassy-sync/src/blocking_mutex/mod.rs index a41bc3569..11809c763 100644 --- a/embassy-sync/src/blocking_mutex/mod.rs +++ b/embassy-sync/src/blocking_mutex/mod.rs | |||
| @@ -22,6 +22,7 @@ use self::raw::RawMutex; | |||
| 22 | /// | 22 | /// |
| 23 | /// In all cases, the blocking mutex is intended to be short lived and not held across await points. | 23 | /// In all cases, the blocking mutex is intended to be short lived and not held across await points. |
| 24 | /// Use the async [`Mutex`](crate::mutex::Mutex) if you need a lock that is held across await points. | 24 | /// Use the async [`Mutex`](crate::mutex::Mutex) if you need a lock that is held across await points. |
| 25 | #[derive(Debug)] | ||
| 25 | pub struct Mutex<R, T: ?Sized> { | 26 | pub struct Mutex<R, T: ?Sized> { |
| 26 | // NOTE: `raw` must be FIRST, so when using ThreadModeMutex the "can't drop in non-thread-mode" gets | 27 | // NOTE: `raw` must be FIRST, so when using ThreadModeMutex the "can't drop in non-thread-mode" gets |
| 27 | // to run BEFORE dropping `data`. | 28 | // to run BEFORE dropping `data`. |
diff --git a/embassy-sync/src/blocking_mutex/raw.rs b/embassy-sync/src/blocking_mutex/raw.rs index a8afcad34..50f965e00 100644 --- a/embassy-sync/src/blocking_mutex/raw.rs +++ b/embassy-sync/src/blocking_mutex/raw.rs | |||
| @@ -37,6 +37,7 @@ pub unsafe trait RawMutex { | |||
| 37 | /// # Safety | 37 | /// # Safety |
| 38 | /// | 38 | /// |
| 39 | /// This mutex is safe to share between different executors and interrupts. | 39 | /// This mutex is safe to share between different executors and interrupts. |
| 40 | #[derive(Debug)] | ||
| 40 | pub struct CriticalSectionRawMutex { | 41 | pub struct CriticalSectionRawMutex { |
| 41 | _phantom: PhantomData<()>, | 42 | _phantom: PhantomData<()>, |
| 42 | } | 43 | } |
| @@ -65,6 +66,7 @@ unsafe impl RawMutex for CriticalSectionRawMutex { | |||
| 65 | /// # Safety | 66 | /// # Safety |
| 66 | /// | 67 | /// |
| 67 | /// **This Mutex is only safe within a single executor.** | 68 | /// **This Mutex is only safe within a single executor.** |
| 69 | #[derive(Debug)] | ||
| 68 | pub struct NoopRawMutex { | 70 | pub struct NoopRawMutex { |
| 69 | _phantom: PhantomData<*mut ()>, | 71 | _phantom: PhantomData<*mut ()>, |
| 70 | } | 72 | } |
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index 8e9fcc234..de437cc52 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -55,6 +55,7 @@ use crate::blocking_mutex::Mutex; | |||
| 55 | use crate::waitqueue::WakerRegistration; | 55 | use crate::waitqueue::WakerRegistration; |
| 56 | 56 | ||
| 57 | /// Send-only access to a [`Channel`]. | 57 | /// Send-only access to a [`Channel`]. |
| 58 | #[derive(Debug)] | ||
| 58 | pub struct Sender<'ch, M, T, const N: usize> | 59 | pub struct Sender<'ch, M, T, const N: usize> |
| 59 | where | 60 | where |
| 60 | M: RawMutex, | 61 | M: RawMutex, |
| @@ -241,6 +242,7 @@ impl<'ch, T> SendDynamicSender<'ch, T> { | |||
| 241 | } | 242 | } |
| 242 | 243 | ||
| 243 | /// Receive-only access to a [`Channel`]. | 244 | /// Receive-only access to a [`Channel`]. |
| 245 | #[derive(Debug)] | ||
| 244 | pub struct Receiver<'ch, M, T, const N: usize> | 246 | pub struct Receiver<'ch, M, T, const N: usize> |
| 245 | where | 247 | where |
| 246 | M: RawMutex, | 248 | M: RawMutex, |
| @@ -486,6 +488,7 @@ where | |||
| 486 | 488 | ||
| 487 | /// Future returned by [`Channel::receive`] and [`Receiver::receive`]. | 489 | /// Future returned by [`Channel::receive`] and [`Receiver::receive`]. |
| 488 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 490 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 491 | #[derive(Debug)] | ||
| 489 | pub struct ReceiveFuture<'ch, M, T, const N: usize> | 492 | pub struct ReceiveFuture<'ch, M, T, const N: usize> |
| 490 | where | 493 | where |
| 491 | M: RawMutex, | 494 | M: RawMutex, |
| @@ -506,6 +509,7 @@ where | |||
| 506 | 509 | ||
| 507 | /// Future returned by [`Channel::ready_to_receive`] and [`Receiver::ready_to_receive`]. | 510 | /// Future returned by [`Channel::ready_to_receive`] and [`Receiver::ready_to_receive`]. |
| 508 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 511 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 512 | #[derive(Debug)] | ||
| 509 | pub struct ReceiveReadyFuture<'ch, M, T, const N: usize> | 513 | pub struct ReceiveReadyFuture<'ch, M, T, const N: usize> |
| 510 | where | 514 | where |
| 511 | M: RawMutex, | 515 | M: RawMutex, |
| @@ -549,6 +553,7 @@ impl<'ch, M: RawMutex, T, const N: usize> From<ReceiveFuture<'ch, M, T, N>> for | |||
| 549 | 553 | ||
| 550 | /// Future returned by [`Channel::send`] and [`Sender::send`]. | 554 | /// Future returned by [`Channel::send`] and [`Sender::send`]. |
| 551 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 555 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 556 | #[derive(Debug)] | ||
| 552 | pub struct SendFuture<'ch, M, T, const N: usize> | 557 | pub struct SendFuture<'ch, M, T, const N: usize> |
| 553 | where | 558 | where |
| 554 | M: RawMutex, | 559 | M: RawMutex, |
| @@ -646,6 +651,7 @@ pub enum TrySendError<T> { | |||
| 646 | Full(T), | 651 | Full(T), |
| 647 | } | 652 | } |
| 648 | 653 | ||
| 654 | #[derive(Debug)] | ||
| 649 | struct ChannelState<T, const N: usize> { | 655 | struct ChannelState<T, const N: usize> { |
| 650 | queue: Deque<T, N>, | 656 | queue: Deque<T, N>, |
| 651 | receiver_waker: WakerRegistration, | 657 | receiver_waker: WakerRegistration, |
| @@ -785,6 +791,7 @@ impl<T, const N: usize> ChannelState<T, N> { | |||
| 785 | /// received from the channel. | 791 | /// received from the channel. |
| 786 | /// | 792 | /// |
| 787 | /// All data sent will become available in the same order as it was sent. | 793 | /// All data sent will become available in the same order as it was sent. |
| 794 | #[derive(Debug)] | ||
| 788 | pub struct Channel<M, T, const N: usize> | 795 | pub struct Channel<M, T, const N: usize> |
| 789 | where | 796 | where |
| 790 | M: RawMutex, | 797 | M: RawMutex, |
diff --git a/embassy-sync/src/lazy_lock.rs b/embassy-sync/src/lazy_lock.rs index a919f0037..945560a80 100644 --- a/embassy-sync/src/lazy_lock.rs +++ b/embassy-sync/src/lazy_lock.rs | |||
| @@ -21,6 +21,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; | |||
| 21 | /// let reference = VALUE.get(); | 21 | /// let reference = VALUE.get(); |
| 22 | /// assert_eq!(reference, &20); | 22 | /// assert_eq!(reference, &20); |
| 23 | /// ``` | 23 | /// ``` |
| 24 | #[derive(Debug)] | ||
| 24 | pub struct LazyLock<T, F = fn() -> T> { | 25 | pub struct LazyLock<T, F = fn() -> T> { |
| 25 | init: AtomicBool, | 26 | init: AtomicBool, |
| 26 | data: UnsafeCell<Data<T, F>>, | 27 | data: UnsafeCell<Data<T, F>>, |
| @@ -144,6 +145,7 @@ mod tests { | |||
| 144 | } | 145 | } |
| 145 | 146 | ||
| 146 | static DROP_CHECKER: AtomicU32 = AtomicU32::new(0); | 147 | static DROP_CHECKER: AtomicU32 = AtomicU32::new(0); |
| 148 | #[derive(Debug)] | ||
| 147 | struct DropCheck; | 149 | struct DropCheck; |
| 148 | 150 | ||
| 149 | impl Drop for DropCheck { | 151 | impl Drop for DropCheck { |
diff --git a/embassy-sync/src/mutex.rs b/embassy-sync/src/mutex.rs index 8496f34bf..4ce6dd987 100644 --- a/embassy-sync/src/mutex.rs +++ b/embassy-sync/src/mutex.rs | |||
| @@ -16,6 +16,7 @@ use crate::waitqueue::WakerRegistration; | |||
| 16 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 16 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 17 | pub struct TryLockError; | 17 | pub struct TryLockError; |
| 18 | 18 | ||
| 19 | #[derive(Debug)] | ||
| 19 | struct State { | 20 | struct State { |
| 20 | locked: bool, | 21 | locked: bool, |
| 21 | waker: WakerRegistration, | 22 | waker: WakerRegistration, |
diff --git a/embassy-sync/src/once_lock.rs b/embassy-sync/src/once_lock.rs index 1e848685a..73edfea9a 100644 --- a/embassy-sync/src/once_lock.rs +++ b/embassy-sync/src/once_lock.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | //! Synchronization primitive for initializing a value once, allowing others to await a reference to the value. | 1 | //! Synchronization primitive for initializing a value once, allowing others to await a reference to the value. |
| 2 | 2 | ||
| 3 | use core::cell::Cell; | 3 | use core::cell::Cell; |
| 4 | use core::fmt::{Debug, Formatter}; | ||
| 4 | use core::future::{poll_fn, Future}; | 5 | use core::future::{poll_fn, Future}; |
| 5 | use core::mem::MaybeUninit; | 6 | use core::mem::MaybeUninit; |
| 6 | use core::sync::atomic::{AtomicBool, Ordering}; | 7 | use core::sync::atomic::{AtomicBool, Ordering}; |
| @@ -42,6 +43,15 @@ pub struct OnceLock<T> { | |||
| 42 | data: Cell<MaybeUninit<T>>, | 43 | data: Cell<MaybeUninit<T>>, |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 46 | impl<T> Debug for OnceLock<T> { | ||
| 47 | fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { | ||
| 48 | f.debug_struct("OnceLock") | ||
| 49 | .field("init", &self.init) | ||
| 50 | .field("data", &"Cell<MaybeUninit<{unprintable}>>") | ||
| 51 | .finish() | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 45 | unsafe impl<T> Sync for OnceLock<T> where T: Sync {} | 55 | unsafe impl<T> Sync for OnceLock<T> where T: Sync {} |
| 46 | 56 | ||
| 47 | impl<T> OnceLock<T> { | 57 | impl<T> OnceLock<T> { |
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index df3b28b45..6d624979a 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -13,6 +13,7 @@ use crate::ring_buffer::RingBuffer; | |||
| 13 | use crate::waitqueue::WakerRegistration; | 13 | use crate::waitqueue::WakerRegistration; |
| 14 | 14 | ||
| 15 | /// Write-only access to a [`Pipe`]. | 15 | /// Write-only access to a [`Pipe`]. |
| 16 | #[derive(Debug)] | ||
| 16 | pub struct Writer<'p, M, const N: usize> | 17 | pub struct Writer<'p, M, const N: usize> |
| 17 | where | 18 | where |
| 18 | M: RawMutex, | 19 | M: RawMutex, |
| @@ -52,6 +53,7 @@ where | |||
| 52 | 53 | ||
| 53 | /// Future returned by [`Pipe::write`] and [`Writer::write`]. | 54 | /// Future returned by [`Pipe::write`] and [`Writer::write`]. |
| 54 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 55 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 56 | #[derive(Debug)] | ||
| 55 | pub struct WriteFuture<'p, M, const N: usize> | 57 | pub struct WriteFuture<'p, M, const N: usize> |
| 56 | where | 58 | where |
| 57 | M: RawMutex, | 59 | M: RawMutex, |
| @@ -77,6 +79,7 @@ where | |||
| 77 | impl<'p, M, const N: usize> Unpin for WriteFuture<'p, M, N> where M: RawMutex {} | 79 | impl<'p, M, const N: usize> Unpin for WriteFuture<'p, M, N> where M: RawMutex {} |
| 78 | 80 | ||
| 79 | /// Read-only access to a [`Pipe`]. | 81 | /// Read-only access to a [`Pipe`]. |
| 82 | #[derive(Debug)] | ||
| 80 | pub struct Reader<'p, M, const N: usize> | 83 | pub struct Reader<'p, M, const N: usize> |
| 81 | where | 84 | where |
| 82 | M: RawMutex, | 85 | M: RawMutex, |
| @@ -128,6 +131,7 @@ where | |||
| 128 | 131 | ||
| 129 | /// Future returned by [`Pipe::read`] and [`Reader::read`]. | 132 | /// Future returned by [`Pipe::read`] and [`Reader::read`]. |
| 130 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 133 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 134 | #[derive(Debug)] | ||
| 131 | pub struct ReadFuture<'p, M, const N: usize> | 135 | pub struct ReadFuture<'p, M, const N: usize> |
| 132 | where | 136 | where |
| 133 | M: RawMutex, | 137 | M: RawMutex, |
| @@ -154,6 +158,7 @@ impl<'p, M, const N: usize> Unpin for ReadFuture<'p, M, N> where M: RawMutex {} | |||
| 154 | 158 | ||
| 155 | /// Future returned by [`Reader::fill_buf`]. | 159 | /// Future returned by [`Reader::fill_buf`]. |
| 156 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 160 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 161 | #[derive(Debug)] | ||
| 157 | pub struct FillBufFuture<'p, M, const N: usize> | 162 | pub struct FillBufFuture<'p, M, const N: usize> |
| 158 | where | 163 | where |
| 159 | M: RawMutex, | 164 | M: RawMutex, |
| @@ -199,6 +204,7 @@ pub enum TryWriteError { | |||
| 199 | Full, | 204 | Full, |
| 200 | } | 205 | } |
| 201 | 206 | ||
| 207 | #[derive(Debug)] | ||
| 202 | struct PipeState<const N: usize> { | 208 | struct PipeState<const N: usize> { |
| 203 | buffer: RingBuffer<N>, | 209 | buffer: RingBuffer<N>, |
| 204 | read_waker: WakerRegistration, | 210 | read_waker: WakerRegistration, |
| @@ -206,6 +212,7 @@ struct PipeState<const N: usize> { | |||
| 206 | } | 212 | } |
| 207 | 213 | ||
| 208 | #[repr(transparent)] | 214 | #[repr(transparent)] |
| 215 | #[derive(Debug)] | ||
| 209 | struct Buffer<const N: usize>(UnsafeCell<[u8; N]>); | 216 | struct Buffer<const N: usize>(UnsafeCell<[u8; N]>); |
| 210 | 217 | ||
| 211 | impl<const N: usize> Buffer<N> { | 218 | impl<const N: usize> Buffer<N> { |
| @@ -230,6 +237,7 @@ unsafe impl<const N: usize> Sync for Buffer<N> {} | |||
| 230 | /// buffer is full, attempts to `write` new bytes will wait until buffer space is freed up. | 237 | /// buffer is full, attempts to `write` new bytes will wait until buffer space is freed up. |
| 231 | /// | 238 | /// |
| 232 | /// All data written will become available in the same order as it was written. | 239 | /// All data written will become available in the same order as it was written. |
| 240 | #[derive(Debug)] | ||
| 233 | pub struct Pipe<M, const N: usize> | 241 | pub struct Pipe<M, const N: usize> |
| 234 | where | 242 | where |
| 235 | M: RawMutex, | 243 | M: RawMutex, |
diff --git a/embassy-sync/src/pubsub/mod.rs b/embassy-sync/src/pubsub/mod.rs index 9206b9383..ad9402f5a 100644 --- a/embassy-sync/src/pubsub/mod.rs +++ b/embassy-sync/src/pubsub/mod.rs | |||
| @@ -71,6 +71,7 @@ pub use subscriber::{DynSubscriber, Subscriber}; | |||
| 71 | /// # block_on(test); | 71 | /// # block_on(test); |
| 72 | /// ``` | 72 | /// ``` |
| 73 | /// | 73 | /// |
| 74 | #[derive(Debug)] | ||
| 74 | pub struct PubSubChannel<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> { | 75 | pub struct PubSubChannel<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> { |
| 75 | inner: Mutex<M, RefCell<PubSubState<T, CAP, SUBS, PUBS>>>, | 76 | inner: Mutex<M, RefCell<PubSubState<T, CAP, SUBS, PUBS>>>, |
| 76 | } | 77 | } |
| @@ -297,6 +298,7 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi | |||
| 297 | } | 298 | } |
| 298 | 299 | ||
| 299 | /// Internal state for the PubSub channel | 300 | /// Internal state for the PubSub channel |
| 301 | #[derive(Debug)] | ||
| 300 | struct PubSubState<T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> { | 302 | struct PubSubState<T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> { |
| 301 | /// The queue contains the last messages that have been published and a countdown of how many subscribers are yet to read it | 303 | /// The queue contains the last messages that have been published and a countdown of how many subscribers are yet to read it |
| 302 | queue: Deque<(T, usize), CAP>, | 304 | queue: Deque<(T, usize), CAP>, |
diff --git a/embassy-sync/src/pubsub/publisher.rs b/embassy-sync/src/pubsub/publisher.rs index 52a52f926..2a67a0002 100644 --- a/embassy-sync/src/pubsub/publisher.rs +++ b/embassy-sync/src/pubsub/publisher.rs | |||
| @@ -10,6 +10,7 @@ use super::{PubSubBehavior, PubSubChannel}; | |||
| 10 | use crate::blocking_mutex::raw::RawMutex; | 10 | use crate::blocking_mutex::raw::RawMutex; |
| 11 | 11 | ||
| 12 | /// A publisher to a channel | 12 | /// A publisher to a channel |
| 13 | #[derive(Debug)] | ||
| 13 | pub struct Pub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { | 14 | pub struct Pub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { |
| 14 | /// The channel we are a publisher for | 15 | /// The channel we are a publisher for |
| 15 | channel: &'a PSB, | 16 | channel: &'a PSB, |
| @@ -106,6 +107,7 @@ impl<'a, T: Clone> DerefMut for DynPublisher<'a, T> { | |||
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | /// A publisher that holds a generic reference to the channel | 109 | /// A publisher that holds a generic reference to the channel |
| 110 | #[derive(Debug)] | ||
| 109 | pub struct Publisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( | 111 | pub struct Publisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( |
| 110 | pub(super) Pub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, | 112 | pub(super) Pub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, |
| 111 | ); | 113 | ); |
| @@ -130,6 +132,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: | |||
| 130 | 132 | ||
| 131 | /// A publisher that can only use the `publish_immediate` function, but it doesn't have to be registered with the channel. | 133 | /// A publisher that can only use the `publish_immediate` function, but it doesn't have to be registered with the channel. |
| 132 | /// (So an infinite amount is possible) | 134 | /// (So an infinite amount is possible) |
| 135 | #[derive(Debug)] | ||
| 133 | pub struct ImmediatePub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { | 136 | pub struct ImmediatePub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { |
| 134 | /// The channel we are a publisher for | 137 | /// The channel we are a publisher for |
| 135 | channel: &'a PSB, | 138 | channel: &'a PSB, |
| @@ -205,6 +208,7 @@ impl<'a, T: Clone> DerefMut for DynImmediatePublisher<'a, T> { | |||
| 205 | } | 208 | } |
| 206 | 209 | ||
| 207 | /// An immediate publisher that holds a generic reference to the channel | 210 | /// An immediate publisher that holds a generic reference to the channel |
| 211 | #[derive(Debug)] | ||
| 208 | pub struct ImmediatePublisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( | 212 | pub struct ImmediatePublisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( |
| 209 | pub(super) ImmediatePub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, | 213 | pub(super) ImmediatePub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, |
| 210 | ); | 214 | ); |
| @@ -229,6 +233,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: | |||
| 229 | 233 | ||
| 230 | #[must_use = "Sinks do nothing unless polled"] | 234 | #[must_use = "Sinks do nothing unless polled"] |
| 231 | /// [`futures_sink::Sink`] adapter for [`Pub`]. | 235 | /// [`futures_sink::Sink`] adapter for [`Pub`]. |
| 236 | #[derive(Debug)] | ||
| 232 | pub struct PubSink<'a, 'p, PSB, T> | 237 | pub struct PubSink<'a, 'p, PSB, T> |
| 233 | where | 238 | where |
| 234 | T: Clone, | 239 | T: Clone, |
| @@ -290,6 +295,7 @@ where | |||
| 290 | 295 | ||
| 291 | /// Future for the publisher wait action | 296 | /// Future for the publisher wait action |
| 292 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 297 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 298 | #[derive(Debug)] | ||
| 293 | pub struct PublisherWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { | 299 | pub struct PublisherWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { |
| 294 | /// The message we need to publish | 300 | /// The message we need to publish |
| 295 | message: Option<T>, | 301 | message: Option<T>, |
diff --git a/embassy-sync/src/pubsub/subscriber.rs b/embassy-sync/src/pubsub/subscriber.rs index 649382cf1..356de23f6 100644 --- a/embassy-sync/src/pubsub/subscriber.rs +++ b/embassy-sync/src/pubsub/subscriber.rs | |||
| @@ -10,6 +10,7 @@ use super::{PubSubBehavior, PubSubChannel, WaitResult}; | |||
| 10 | use crate::blocking_mutex::raw::RawMutex; | 10 | use crate::blocking_mutex::raw::RawMutex; |
| 11 | 11 | ||
| 12 | /// A subscriber to a channel | 12 | /// A subscriber to a channel |
| 13 | #[derive(Debug)] | ||
| 13 | pub struct Sub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { | 14 | pub struct Sub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { |
| 14 | /// The message id of the next message we are yet to receive | 15 | /// The message id of the next message we are yet to receive |
| 15 | next_message_id: u64, | 16 | next_message_id: u64, |
| @@ -151,6 +152,7 @@ impl<'a, T: Clone> DerefMut for DynSubscriber<'a, T> { | |||
| 151 | } | 152 | } |
| 152 | 153 | ||
| 153 | /// A subscriber that holds a generic reference to the channel | 154 | /// A subscriber that holds a generic reference to the channel |
| 155 | #[derive(Debug)] | ||
| 154 | pub struct Subscriber<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( | 156 | pub struct Subscriber<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( |
| 155 | pub(super) Sub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, | 157 | pub(super) Sub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, |
| 156 | ); | 158 | ); |
| @@ -175,6 +177,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: | |||
| 175 | 177 | ||
| 176 | /// Future for the subscriber wait action | 178 | /// Future for the subscriber wait action |
| 177 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 179 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 180 | #[derive(Debug)] | ||
| 178 | pub struct SubscriberWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { | 181 | pub struct SubscriberWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { |
| 179 | subscriber: &'s mut Sub<'a, PSB, T>, | 182 | subscriber: &'s mut Sub<'a, PSB, T>, |
| 180 | } | 183 | } |
diff --git a/embassy-sync/src/ring_buffer.rs b/embassy-sync/src/ring_buffer.rs index 81e60c42b..f03b7dd8f 100644 --- a/embassy-sync/src/ring_buffer.rs +++ b/embassy-sync/src/ring_buffer.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | use core::ops::Range; | 1 | use core::ops::Range; |
| 2 | 2 | ||
| 3 | #[derive(Debug)] | ||
| 3 | pub struct RingBuffer<const N: usize> { | 4 | pub struct RingBuffer<const N: usize> { |
| 4 | start: usize, | 5 | start: usize, |
| 5 | end: usize, | 6 | end: usize, |
diff --git a/embassy-sync/src/rwlock.rs b/embassy-sync/src/rwlock.rs index deeadd167..0d784a7dc 100644 --- a/embassy-sync/src/rwlock.rs +++ b/embassy-sync/src/rwlock.rs | |||
| @@ -16,6 +16,7 @@ use crate::waitqueue::WakerRegistration; | |||
| 16 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 16 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 17 | pub struct TryLockError; | 17 | pub struct TryLockError; |
| 18 | 18 | ||
| 19 | #[derive(Debug)] | ||
| 19 | struct State { | 20 | struct State { |
| 20 | readers: usize, | 21 | readers: usize, |
| 21 | writer: bool, | 22 | writer: bool, |
diff --git a/embassy-sync/src/semaphore.rs b/embassy-sync/src/semaphore.rs index d30eee30b..4e82b0fcd 100644 --- a/embassy-sync/src/semaphore.rs +++ b/embassy-sync/src/semaphore.rs | |||
| @@ -46,6 +46,7 @@ pub trait Semaphore: Sized { | |||
| 46 | /// A representation of a number of acquired permits. | 46 | /// A representation of a number of acquired permits. |
| 47 | /// | 47 | /// |
| 48 | /// The acquired permits will be released back to the [`Semaphore`] when this is dropped. | 48 | /// The acquired permits will be released back to the [`Semaphore`] when this is dropped. |
| 49 | #[derive(Debug)] | ||
| 49 | pub struct SemaphoreReleaser<'a, S: Semaphore> { | 50 | pub struct SemaphoreReleaser<'a, S: Semaphore> { |
| 50 | semaphore: &'a S, | 51 | semaphore: &'a S, |
| 51 | permits: usize, | 52 | permits: usize, |
| @@ -181,6 +182,7 @@ impl<M: RawMutex> Semaphore for GreedySemaphore<M> { | |||
| 181 | } | 182 | } |
| 182 | } | 183 | } |
| 183 | 184 | ||
| 185 | #[derive(Debug)] | ||
| 184 | struct SemaphoreState { | 186 | struct SemaphoreState { |
| 185 | permits: usize, | 187 | permits: usize, |
| 186 | waker: WakerRegistration, | 188 | waker: WakerRegistration, |
| @@ -221,6 +223,7 @@ impl SemaphoreState { | |||
| 221 | /// | 223 | /// |
| 222 | /// Up to `N` tasks may attempt to acquire permits concurrently. If additional | 224 | /// Up to `N` tasks may attempt to acquire permits concurrently. If additional |
| 223 | /// tasks attempt to acquire a permit, a [`WaitQueueFull`] error will be returned. | 225 | /// tasks attempt to acquire a permit, a [`WaitQueueFull`] error will be returned. |
| 226 | #[derive(Debug)] | ||
| 224 | pub struct FairSemaphore<M, const N: usize> | 227 | pub struct FairSemaphore<M, const N: usize> |
| 225 | where | 228 | where |
| 226 | M: RawMutex, | 229 | M: RawMutex, |
| @@ -341,6 +344,7 @@ impl<M: RawMutex, const N: usize> Semaphore for FairSemaphore<M, N> { | |||
| 341 | } | 344 | } |
| 342 | } | 345 | } |
| 343 | 346 | ||
| 347 | #[derive(Debug)] | ||
| 344 | struct FairAcquire<'a, M: RawMutex, const N: usize> { | 348 | struct FairAcquire<'a, M: RawMutex, const N: usize> { |
| 345 | sema: &'a FairSemaphore<M, N>, | 349 | sema: &'a FairSemaphore<M, N>, |
| 346 | permits: usize, | 350 | permits: usize, |
| @@ -364,6 +368,7 @@ impl<'a, M: RawMutex, const N: usize> core::future::Future for FairAcquire<'a, M | |||
| 364 | } | 368 | } |
| 365 | } | 369 | } |
| 366 | 370 | ||
| 371 | #[derive(Debug)] | ||
| 367 | struct FairAcquireAll<'a, M: RawMutex, const N: usize> { | 372 | struct FairAcquireAll<'a, M: RawMutex, const N: usize> { |
| 368 | sema: &'a FairSemaphore<M, N>, | 373 | sema: &'a FairSemaphore<M, N>, |
| 369 | min: usize, | 374 | min: usize, |
| @@ -387,6 +392,7 @@ impl<'a, M: RawMutex, const N: usize> core::future::Future for FairAcquireAll<'a | |||
| 387 | } | 392 | } |
| 388 | } | 393 | } |
| 389 | 394 | ||
| 395 | #[derive(Debug)] | ||
| 390 | struct FairSemaphoreState<const N: usize> { | 396 | struct FairSemaphoreState<const N: usize> { |
| 391 | permits: usize, | 397 | permits: usize, |
| 392 | next_ticket: usize, | 398 | next_ticket: usize, |
diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs index e7095401e..d96e36245 100644 --- a/embassy-sync/src/signal.rs +++ b/embassy-sync/src/signal.rs | |||
| @@ -39,6 +39,7 @@ where | |||
| 39 | state: Mutex<M, Cell<State<T>>>, | 39 | state: Mutex<M, Cell<State<T>>>, |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | #[derive(Debug)] | ||
| 42 | enum State<T> { | 43 | enum State<T> { |
| 43 | None, | 44 | None, |
| 44 | Waiting(Waker), | 45 | Waiting(Waker), |
diff --git a/embassy-sync/src/waitqueue/atomic_waker_turbo.rs b/embassy-sync/src/waitqueue/atomic_waker_turbo.rs index c06b83056..a45adeab8 100644 --- a/embassy-sync/src/waitqueue/atomic_waker_turbo.rs +++ b/embassy-sync/src/waitqueue/atomic_waker_turbo.rs | |||
| @@ -7,6 +7,7 @@ use core::task::Waker; | |||
| 7 | /// If a waker is registered, registering another waker will replace the previous one without waking it. | 7 | /// If a waker is registered, registering another waker will replace the previous one without waking it. |
| 8 | /// The intended use case is to wake tasks from interrupts. Therefore, it is generally not expected, | 8 | /// The intended use case is to wake tasks from interrupts. Therefore, it is generally not expected, |
| 9 | /// that multiple tasks register try to register a waker simultaneously. | 9 | /// that multiple tasks register try to register a waker simultaneously. |
| 10 | #[derive(Debug)] | ||
| 10 | pub struct AtomicWaker { | 11 | pub struct AtomicWaker { |
| 11 | waker: AtomicPtr<()>, | 12 | waker: AtomicPtr<()>, |
| 12 | } | 13 | } |
diff --git a/embassy-sync/src/waitqueue/multi_waker.rs b/embassy-sync/src/waitqueue/multi_waker.rs index 1c05f8eaf..56c0cd1b2 100644 --- a/embassy-sync/src/waitqueue/multi_waker.rs +++ b/embassy-sync/src/waitqueue/multi_waker.rs | |||
| @@ -5,6 +5,7 @@ use heapless::Vec; | |||
| 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`. | 6 | /// Queue of wakers with a maximum length of `N`. |
| 7 | /// Intended for waking multiple tasks. | 7 | /// Intended for waking multiple tasks. |
| 8 | #[derive(Debug)] | ||
| 8 | pub struct MultiWakerRegistration<const N: usize> { | 9 | pub struct MultiWakerRegistration<const N: usize> { |
| 9 | wakers: Vec<Waker, N>, | 10 | wakers: Vec<Waker, N>, |
| 10 | } | 11 | } |
diff --git a/embassy-sync/src/watch.rs b/embassy-sync/src/watch.rs index 08d6a833d..332ab5405 100644 --- a/embassy-sync/src/watch.rs +++ b/embassy-sync/src/watch.rs | |||
| @@ -65,10 +65,12 @@ use crate::waitqueue::MultiWakerRegistration; | |||
| 65 | /// }; | 65 | /// }; |
| 66 | /// block_on(f); | 66 | /// block_on(f); |
| 67 | /// ``` | 67 | /// ``` |
| 68 | #[derive(Debug)] | ||
| 68 | pub struct Watch<M: RawMutex, T: Clone, const N: usize> { | 69 | pub struct Watch<M: RawMutex, T: Clone, const N: usize> { |
| 69 | mutex: Mutex<M, RefCell<WatchState<T, N>>>, | 70 | mutex: Mutex<M, RefCell<WatchState<T, N>>>, |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 73 | #[derive(Debug)] | ||
| 72 | struct WatchState<T: Clone, const N: usize> { | 74 | struct WatchState<T: Clone, const N: usize> { |
| 73 | data: Option<T>, | 75 | data: Option<T>, |
| 74 | current_id: u64, | 76 | current_id: u64, |
| @@ -392,6 +394,7 @@ impl<M: RawMutex, T: Clone, const N: usize> Watch<M, T, N> { | |||
| 392 | } | 394 | } |
| 393 | 395 | ||
| 394 | /// A receiver can `.await` a change in the `Watch` value. | 396 | /// A receiver can `.await` a change in the `Watch` value. |
| 397 | #[derive(Debug)] | ||
| 395 | pub struct Snd<'a, T: Clone, W: WatchBehavior<T> + ?Sized> { | 398 | pub struct Snd<'a, T: Clone, W: WatchBehavior<T> + ?Sized> { |
| 396 | watch: &'a W, | 399 | watch: &'a W, |
| 397 | _phantom: PhantomData<T>, | 400 | _phantom: PhantomData<T>, |
| @@ -467,6 +470,7 @@ impl<'a, T: Clone, W: WatchBehavior<T> + ?Sized> Snd<'a, T, W> { | |||
| 467 | /// | 470 | /// |
| 468 | /// For a simpler type definition, consider [`DynSender`] at the expense of | 471 | /// For a simpler type definition, consider [`DynSender`] at the expense of |
| 469 | /// some runtime performance due to dynamic dispatch. | 472 | /// some runtime performance due to dynamic dispatch. |
| 473 | #[derive(Debug)] | ||
| 470 | pub struct Sender<'a, M: RawMutex, T: Clone, const N: usize>(Snd<'a, T, Watch<M, T, N>>); | 474 | pub struct Sender<'a, M: RawMutex, T: Clone, const N: usize>(Snd<'a, T, Watch<M, T, N>>); |
| 471 | 475 | ||
| 472 | impl<'a, M: RawMutex, T: Clone, const N: usize> Clone for Sender<'a, M, T, N> { | 476 | impl<'a, M: RawMutex, T: Clone, const N: usize> Clone for Sender<'a, M, T, N> { |
| @@ -622,6 +626,7 @@ impl<'a, T: Clone, W: WatchBehavior<T> + ?Sized> Drop for Rcv<'a, T, W> { | |||
| 622 | } | 626 | } |
| 623 | 627 | ||
| 624 | /// A anonymous receiver can NOT `.await` a change in the `Watch` value. | 628 | /// A anonymous receiver can NOT `.await` a change in the `Watch` value. |
| 629 | #[derive(Debug)] | ||
| 625 | pub struct AnonRcv<'a, T: Clone, W: WatchBehavior<T> + ?Sized> { | 630 | pub struct AnonRcv<'a, T: Clone, W: WatchBehavior<T> + ?Sized> { |
| 626 | watch: &'a W, | 631 | watch: &'a W, |
| 627 | at_id: u64, | 632 | at_id: u64, |
| @@ -726,6 +731,7 @@ impl<'a, T: Clone> DerefMut for DynReceiver<'a, T> { | |||
| 726 | } | 731 | } |
| 727 | 732 | ||
| 728 | /// A receiver of a `Watch` channel that cannot `.await` values. | 733 | /// A receiver of a `Watch` channel that cannot `.await` values. |
| 734 | #[derive(Debug)] | ||
| 729 | pub struct AnonReceiver<'a, M: RawMutex, T: Clone, const N: usize>(AnonRcv<'a, T, Watch<M, T, N>>); | 735 | pub struct AnonReceiver<'a, M: RawMutex, T: Clone, const N: usize>(AnonRcv<'a, T, Watch<M, T, N>>); |
| 730 | 736 | ||
| 731 | impl<'a, M: RawMutex, T: Clone, const N: usize> AnonReceiver<'a, M, T, N> { | 737 | impl<'a, M: RawMutex, T: Clone, const N: usize> AnonReceiver<'a, M, T, N> { |
diff --git a/embassy-sync/src/zerocopy_channel.rs b/embassy-sync/src/zerocopy_channel.rs index e3e5b2538..b3f7dbe8c 100644 --- a/embassy-sync/src/zerocopy_channel.rs +++ b/embassy-sync/src/zerocopy_channel.rs | |||
| @@ -34,6 +34,7 @@ use crate::waitqueue::WakerRegistration; | |||
| 34 | /// | 34 | /// |
| 35 | /// The channel requires a buffer of recyclable elements. Writing to the channel is done through | 35 | /// The channel requires a buffer of recyclable elements. Writing to the channel is done through |
| 36 | /// an `&mut T`. | 36 | /// an `&mut T`. |
| 37 | #[derive(Debug)] | ||
| 37 | pub struct Channel<'a, M: RawMutex, T> { | 38 | pub struct Channel<'a, M: RawMutex, T> { |
| 38 | buf: BufferPtr<T>, | 39 | buf: BufferPtr<T>, |
| 39 | phantom: PhantomData<&'a mut T>, | 40 | phantom: PhantomData<&'a mut T>, |
| @@ -95,6 +96,7 @@ impl<'a, M: RawMutex, T> Channel<'a, M, T> { | |||
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | #[repr(transparent)] | 98 | #[repr(transparent)] |
| 99 | #[derive(Debug)] | ||
| 98 | struct BufferPtr<T>(*mut T); | 100 | struct BufferPtr<T>(*mut T); |
| 99 | 101 | ||
| 100 | impl<T> BufferPtr<T> { | 102 | impl<T> BufferPtr<T> { |
| @@ -107,6 +109,7 @@ unsafe impl<T> Send for BufferPtr<T> {} | |||
| 107 | unsafe impl<T> Sync for BufferPtr<T> {} | 109 | unsafe impl<T> Sync for BufferPtr<T> {} |
| 108 | 110 | ||
| 109 | /// Send-only access to a [`Channel`]. | 111 | /// Send-only access to a [`Channel`]. |
| 112 | #[derive(Debug)] | ||
| 110 | pub struct Sender<'a, M: RawMutex, T> { | 113 | pub struct Sender<'a, M: RawMutex, T> { |
| 111 | channel: &'a Channel<'a, M, T>, | 114 | channel: &'a Channel<'a, M, T>, |
| 112 | } | 115 | } |
| @@ -190,6 +193,7 @@ impl<'a, M: RawMutex, T> Sender<'a, M, T> { | |||
| 190 | } | 193 | } |
| 191 | 194 | ||
| 192 | /// Receive-only access to a [`Channel`]. | 195 | /// Receive-only access to a [`Channel`]. |
| 196 | #[derive(Debug)] | ||
| 193 | pub struct Receiver<'a, M: RawMutex, T> { | 197 | pub struct Receiver<'a, M: RawMutex, T> { |
| 194 | channel: &'a Channel<'a, M, T>, | 198 | channel: &'a Channel<'a, M, T>, |
| 195 | } | 199 | } |
| @@ -272,6 +276,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> { | |||
| 272 | } | 276 | } |
| 273 | } | 277 | } |
| 274 | 278 | ||
| 279 | #[derive(Debug)] | ||
| 275 | struct State { | 280 | struct State { |
| 276 | /// Maximum number of elements the channel can hold. | 281 | /// Maximum number of elements the channel can hold. |
| 277 | capacity: usize, | 282 | capacity: usize, |
