pub struct DaemonManager { /* private fields */ }Expand description
Manages the lifecycle of background daemon threads.
The DaemonManager is responsible for:
- Starting daemon threads (evictor, cleaner, checkpointer)
- Coordinating shutdown of all daemons
- Tracking daemon running state
Each daemon runs in its own thread, periodically waking up to perform work. On shutdown, daemons are notified via a Condvar so they exit immediately instead of sleeping through their full wakeup interval.
Implementations§
Source§impl DaemonManager
impl DaemonManager
Sourcepub fn new(config: &EngineConfig) -> Self
pub fn new(config: &EngineConfig) -> Self
Creates a new DaemonManager from the given configuration.
Daemons are not started until start_daemons() is called.
Sourcepub fn start_daemons(
&mut self,
evictor: Arc<Evictor>,
cleaner: Arc<Cleaner>,
checkpointer: Arc<Checkpointer>,
)
pub fn start_daemons( &mut self, evictor: Arc<Evictor>, cleaner: Arc<Cleaner>, checkpointer: Arc<Checkpointer>, )
Starts all enabled daemon threads.
Each daemon runs in a loop:
- Sleep for its wakeup interval
- Check shutdown flag
- Perform work (eviction, cleaning, checkpoint)
- Repeat
§Arguments
evictor- The evictor to use for eviction operationscleaner- The cleaner to use for cleaning operationscheckpointer- The checkpointer to use for checkpoint operations
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Signals shutdown and waits for all daemon threads to complete.
This method:
- Sets the shutdown flag
- Notifies all sleeping daemons via their Condvar so they wake immediately
- Joins all daemon thread handles
- Waits for all threads to exit cleanly
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true while this manager has not been shut down.
Specifically, this returns true from construction until
shutdown is invoked. It does not prove that
any daemon thread is currently alive: a freshly-constructed manager
(before start_daemons is called) reports
true here while running_count returns 0.
This semantic is codified by test_daemon_manager_creation, which
asserts both is_running() == true and running_count() == 0
before any daemons are started. Use running_count() if you need
the actual count of spawned daemon threads.
Sourcepub fn running_count(&self) -> usize
pub fn running_count(&self) -> usize
Returns the number of running daemons.