aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-sync/src/watch.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/embassy-sync/src/watch.rs b/embassy-sync/src/watch.rs
index 59798d04f..404e31714 100644
--- a/embassy-sync/src/watch.rs
+++ b/embassy-sync/src/watch.rs
@@ -310,6 +310,18 @@ impl<M: RawMutex, T: Clone, const N: usize> Watch<M, T, N> {
310 } 310 }
311 } 311 }
312 312
313 /// Create a new `Watch` channel with default data.
314 pub const fn new_with(data: T) -> Self {
315 Self {
316 mutex: Mutex::new(RefCell::new(WatchState {
317 data: Some(data),
318 current_id: 0,
319 wakers: MultiWakerRegistration::new(),
320 receiver_count: 0,
321 })),
322 }
323 }
324
313 /// Create a new [`Sender`] for the `Watch`. 325 /// Create a new [`Sender`] for the `Watch`.
314 pub fn sender(&self) -> Sender<'_, M, T, N> { 326 pub fn sender(&self) -> Sender<'_, M, T, N> {
315 Sender(Snd::new(self)) 327 Sender(Snd::new(self))