pub struct FrameTickRegistry { /* private fields */ }Expand description
Stable-slot, priority-ordered registry of FrameTickHook participants with O(1) idle and
future-deadline checks and zero steady-state allocations.
Slot indices are monotonically assigned and never shifted on priority insert or removal so
external SlotWaker handles always address their exact slot (wakes for removed slots are
masked out via live_mask).
Implementations§
Source§impl FrameTickRegistry
impl FrameTickRegistry
Sourcepub fn with_on_wake(on_wake: Arc<dyn Fn() + Send + Sync>) -> Self
pub fn with_on_wake(on_wake: Arc<dyn Fn() + Send + Sync>) -> Self
Creates an empty registry whose Self::waker and Self::slot_waker invoke on_wake.
Sourcepub fn from_hooks(hooks: Vec<Box<dyn FrameTickHook>>) -> Self
pub fn from_hooks(hooks: Vec<Box<dyn FrameTickHook>>) -> Self
Creates a registry from hooks registered at TickPriority::NORMAL.
Sourcepub fn from_entries_with_on_wake(
entries: Vec<(TickPriority, Box<dyn FrameTickHook>)>,
on_wake: Arc<dyn Fn() + Send + Sync>,
) -> Self
pub fn from_entries_with_on_wake( entries: Vec<(TickPriority, Box<dyn FrameTickHook>)>, on_wake: Arc<dyn Fn() + Send + Sync>, ) -> Self
Creates a registry from (priority, hook) pairs with a bound on_wake callback.
Sourcepub fn waker(&self) -> FrameWaker
pub fn waker(&self) -> FrameWaker
Returns a thread-safe FrameWaker for waking slots from outside tick().
Sourcepub fn slot_waker(&self, slot: usize) -> SlotWaker
pub fn slot_waker(&self, slot: usize) -> SlotWaker
Returns a thread-safe, zero-alloc SlotWaker bound to slot.
Sourcepub fn last_now_ms(&self) -> Option<u64>
pub fn last_now_ms(&self) -> Option<u64>
Returns the last monotonic timestamp observed by this registry, if any.
Sourcepub fn push(
&mut self,
hook: Box<dyn FrameTickHook>,
) -> (TickHookId, usize, TickDemand)
pub fn push( &mut self, hook: Box<dyn FrameTickHook>, ) -> (TickHookId, usize, TickDemand)
Registers a hook at TickPriority::NORMAL, returning (id, stable_slot, initial_demand).
Sourcepub fn push_with_priority(
&mut self,
priority: TickPriority,
hook: Box<dyn FrameTickHook>,
) -> (TickHookId, usize, TickDemand)
pub fn push_with_priority( &mut self, priority: TickPriority, hook: Box<dyn FrameTickHook>, ) -> (TickHookId, usize, TickDemand)
Registers a hook at priority without shifting any existing slot index, returning
(id, stable_slot, initial_demand).
Sourcepub fn push_with_priority_at(
&mut self,
priority: TickPriority,
hook: Box<dyn FrameTickHook>,
now_ms: u64,
) -> (TickHookId, usize, TickDemand)
pub fn push_with_priority_at( &mut self, priority: TickPriority, hook: Box<dyn FrameTickHook>, now_ms: u64, ) -> (TickHookId, usize, TickDemand)
Registers a hook at priority anchoring any initial TickDemand::AfterMs deadline to
monotonic now_ms (and advancing last_now_ms monotonically).
Sourcepub fn remove(&mut self, id: TickHookId) -> bool
pub fn remove(&mut self, id: TickHookId) -> bool
Removes the hook identified by id without shifting any other slot’s index.
Sourcepub fn has_pending_wakes(&self) -> bool
pub fn has_pending_wakes(&self) -> bool
Returns true if a FrameWaker woke a live slot since the last drain.
Sourcepub fn refresh_active(&mut self, now_ms: u64)
pub fn refresh_active(&mut self, now_ms: u64)
Queries every live hook’s FrameTickHook::demand after a store commit and merges any
newly active/timed demands into the schedule (sticky: never clears woken slots or pushes
existing deadlines forward).
Sourcepub fn refresh_active_with_store(
&mut self,
store: &NodeStore,
changes: &ChangeSet,
now_ms: u64,
)
pub fn refresh_active_with_store( &mut self, store: &NodeStore, changes: &ChangeSet, now_ms: u64, )
Store-aware variant of Self::refresh_active calling FrameTickHook::demand_on_commit
so store-scanning hooks skip unrelated commits with zero allocations.
Sourcepub fn has_due(&mut self, now_ms: u64) -> bool
pub fn has_due(&mut self, now_ms: u64) -> bool
Returns true if any live hook is due at now_ms (O(1) fast path when idle or waiting
on a future deadline).
Sourcepub fn next_demand(&mut self, now_ms: u64) -> TickDemand
pub fn next_demand(&mut self, now_ms: u64) -> TickDemand
Returns the aggregate TickDemand across all live hooks at now_ms in O(1) time with
zero allocations.
Sourcepub fn tick_active(
&mut self,
tx: &mut Transaction<'_>,
dt_s: f32,
now_ms: u64,
) -> TickDemand
pub fn tick_active( &mut self, tx: &mut Transaction<'_>, dt_s: f32, now_ms: u64, ) -> TickDemand
Ticks all due hooks in strict (priority ASC, id ASC) order and returns the merged
TickDemand across ALL live hooks (including non-due timed hooks).