Skip to main content

Daemon

Struct Daemon 

Source
pub struct Daemon<K, V, S> {
Show 15 fields pub hasher: S, pub arena: Arena, pub t1: Arc<T1<K, V>>, pub t2: Arc<T2<K, V>>, pub cache: Arc<Cache<K, V>>, pub cmd_rx: Arc<LossyQueue<Command<K, V>>>, pub hit_rx: Arc<LossyQueue<[usize; 64]>>, pub epoch: Arc<AtomicU32>, pub poll_us: u64, pub admission: Arc<AdmissionFilter>, pub hit_accumulator: Vec<usize>, pub last_decay_epoch: u32, pub garbage_queue: Vec<(*mut Node<K, V>, usize)>, pub worker_states: Arc<[WorkerState]>, pub daemon_tick: Arc<AtomicU64>,
}

Fields§

§hasher: S§arena: Arena§t1: Arc<T1<K, V>>§t2: Arc<T2<K, V>>§cache: Arc<Cache<K, V>>§cmd_rx: Arc<LossyQueue<Command<K, V>>>§hit_rx: Arc<LossyQueue<[usize; 64]>>§epoch: Arc<AtomicU32>§poll_us: u64

Configurable poll interval in microseconds (1 000–10 000 µs). Controls the trade-off between CPU idle cost and hit-signal latency.

§admission: Arc<AdmissionFilter>§hit_accumulator: Vec<usize>

Pre-allocated accumulator for deferred-sort hit processing.

§last_decay_epoch: u32§garbage_queue: Vec<(*mut Node<K, V>, usize)>§worker_states: Arc<[WorkerState]>§daemon_tick: Arc<AtomicU64>

Monotonically increasing tick counter — incremented on every poll loop. Workers read this (Relaxed) to decide whether to time-flush their TLS buffers without needing a hardware clock in no_std mode.

Implementations§

Source§

impl<K, V, S> Daemon<K, V, S>
where K: Hash + Eq + Send + Sync + Clone + 'static, V: Send + Sync + Clone + 'static, S: BuildHasher + Clone + Send + 'static,

Source

pub fn new( hasher: S, capacity: usize, t1: Arc<T1<K, V>>, t2: Arc<T2<K, V>>, cache: Arc<Cache<K, V>>, cmd_rx: Arc<LossyQueue<Command<K, V>>>, hit_rx: Arc<LossyQueue<[usize; 64]>>, epoch: Arc<AtomicU32>, duration: u32, poll_us: u64, worker_states: Arc<[WorkerState]>, daemon_tick: Arc<AtomicU64>, ) -> Self

Source

pub fn run(self)

Main Daemon event loop.

§std mode

Called from a dedicated std::thread::spawn inside DualCacheFF::new. Sleeps poll_us microseconds when the command queue is empty.

§no_std mode

The caller (e.g. RTOS task) must invoke daemon.run() on a dedicated task. The loop uses core::hint::spin_loop() between iterations; the RTOS scheduler handles preemption and CPU sharing.

Trait Implementations§

Source§

impl<K: Send, V: Send, S: Send> Send for Daemon<K, V, S>

Auto Trait Implementations§

§

impl<K, V, S> Freeze for Daemon<K, V, S>
where S: Freeze,

§

impl<K, V, S> !RefUnwindSafe for Daemon<K, V, S>

§

impl<K, V, S> !Sync for Daemon<K, V, S>

§

impl<K, V, S> Unpin for Daemon<K, V, S>
where S: Unpin,

§

impl<K, V, S> UnsafeUnpin for Daemon<K, V, S>
where S: UnsafeUnpin,

§

impl<K, V, S> !UnwindSafe for Daemon<K, V, S>

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.