Skip to content

Commit e506aa9

Browse files
committed
Attempt to update the PR.
Still fails somehow.
1 parent 3e31eb5 commit e506aa9

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/store/fs/util/watch.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ impl<T> Clone for Sender<T> {
2626
pub struct Receiver<T>(Arc<Shared<T>>);
2727

2828
impl<T> Sender<T> {
29-
pub fn new(value: T) -> Self {
30-
Self(Arc::new(Shared {
31-
value: AtomicRefCell::new(State {
32-
value,
33-
dropped: false,
34-
}),
35-
notify: tokio::sync::Notify::new(),
36-
}))
29+
30+
pub fn send_modify<F>(&self, modify: F)
31+
where
32+
F: FnOnce(&mut T),
33+
{
34+
self.send_if_modified(|value| {
35+
modify(value);
36+
true
37+
});
38+
}
39+
40+
pub fn send_replace(&self, mut value: T) -> T {
41+
// swap old watched value with the new one
42+
self.send_modify(|old| std::mem::swap(old, &mut value));
43+
44+
value
3745
}
3846

3947
pub fn send_if_modified<F>(&self, modify: F) -> bool

0 commit comments

Comments
 (0)