From fe43b5706f57a22d323b90685363d2399e8b5552 Mon Sep 17 00:00:00 2001 From: Luna Yao <40349250+ZnqbuZ@users.noreply.github.com> Date: Tue, 31 Mar 2026 16:55:11 +0200 Subject: [PATCH] dirty: fix Default, remove unused DirtyState --- easytier/src/dns/utils/dirty.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/easytier/src/dns/utils/dirty.rs b/easytier/src/dns/utils/dirty.rs index 97fd30e8..7fa690b1 100644 --- a/easytier/src/dns/utils/dirty.rs +++ b/easytier/src/dns/utils/dirty.rs @@ -1,20 +1,9 @@ -use derivative::Derivative; -use derive_more::{Deref, DerefMut}; +use derive_more::Deref; use std::sync::atomic::{AtomicBool, Ordering}; use tokio::sync::Notify; -#[derive(Debug, Default, Deref, DerefMut)] -pub struct DirtyState { - #[deref] - #[deref_mut] - flags: T, - pub notify: Notify, -} - -#[derive(Derivative, Debug, Deref)] -#[derivative(Default)] +#[derive(Debug, Deref)] pub struct DirtyFlag { - #[derivative(Default(value = "AtomicBool::new(true)"))] dirty: AtomicBool, #[deref] notify: Notify, @@ -22,9 +11,15 @@ pub struct DirtyFlag { impl DirtyFlag { pub fn new(value: bool) -> Self { + let notify = Notify::new(); + + if value { + notify.notify_one(); + } + Self { dirty: AtomicBool::new(value), - notify: Notify::new(), + notify, } } @@ -41,3 +36,9 @@ impl DirtyFlag { self.dirty.swap(false, Ordering::Acquire) } } + +impl Default for DirtyFlag { + fn default() -> Self { + Self::new(true) + } +}