Skip to main content

DaemonManager

Struct DaemonManager 

Source
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

Source

pub fn new(config: &EngineConfig) -> Self

Creates a new DaemonManager from the given configuration.

Daemons are not started until start_daemons() is called.

Source

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:

  1. Sleep for its wakeup interval
  2. Check shutdown flag
  3. Perform work (eviction, cleaning, checkpoint)
  4. Repeat
§Arguments
  • evictor - The evictor to use for eviction operations
  • cleaner - The cleaner to use for cleaning operations
  • checkpointer - The checkpointer to use for checkpoint operations
Source

pub fn shutdown(&mut self)

Signals shutdown and waits for all daemon threads to complete.

This method:

  1. Sets the shutdown flag
  2. Notifies all sleeping daemons via their Condvar so they wake immediately
  3. Joins all daemon thread handles
  4. Waits for all threads to exit cleanly
Source

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.

Source

pub fn running_count(&self) -> usize

Returns the number of running daemons.

Trait Implementations§

Source§

impl Drop for DaemonManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.