mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
Merge pull request #3521 from Gibbz/main
embassy_sync::watch default values
This commit is contained in:
commit
d6a8dce6ee
@ -310,6 +310,18 @@ impl<M: RawMutex, T: Clone, const N: usize> Watch<M, T, N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new `Watch` channel with default data.
|
||||||
|
pub const fn new_with(data: T) -> Self {
|
||||||
|
Self {
|
||||||
|
mutex: Mutex::new(RefCell::new(WatchState {
|
||||||
|
data: Some(data),
|
||||||
|
current_id: 0,
|
||||||
|
wakers: MultiWakerRegistration::new(),
|
||||||
|
receiver_count: 0,
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new [`Sender`] for the `Watch`.
|
/// Create a new [`Sender`] for the `Watch`.
|
||||||
pub fn sender(&self) -> Sender<'_, M, T, N> {
|
pub fn sender(&self) -> Sender<'_, M, T, N> {
|
||||||
Sender(Snd::new(self))
|
Sender(Snd::new(self))
|
||||||
|
Loading…
Reference in New Issue
Block a user