node & server: separate dirty flag, remove DirtyState

This commit is contained in:
Luna Yao
2026-02-22 03:34:45 +01:00
parent fcfb0ad6bc
commit 2e1f9bc9cc
5 changed files with 66 additions and 46 deletions
+15 -6
View File
@@ -11,24 +11,33 @@ pub struct DirtyState<T> {
pub notify: Notify,
}
#[derive(Derivative, Debug)]
#[derive(Derivative, Debug, Deref)]
#[derivative(Default)]
pub struct DirtyFlag(#[derivative(Default(value = "AtomicBool::new(true)"))] AtomicBool);
pub struct DirtyFlag {
#[derivative(Default(value = "AtomicBool::new(true)"))]
dirty: AtomicBool,
#[deref]
notify: Notify,
}
impl DirtyFlag {
pub fn new(value: bool) -> Self {
Self(AtomicBool::new(value))
Self {
dirty: AtomicBool::new(value),
notify: Notify::new(),
}
}
pub fn mark(&self) {
self.0.store(true, Ordering::Release);
self.dirty.store(true, Ordering::Release);
self.notify.notify_one();
}
pub fn peek(&self) -> bool {
self.0.load(Ordering::Acquire)
self.dirty.load(Ordering::Acquire)
}
pub fn reset(&self) -> bool {
self.0.swap(false, Ordering::Acquire)
self.dirty.swap(false, Ordering::Acquire)
}
}