Skip to main content

FrameTickRegistry

Struct FrameTickRegistry 

Source
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

Source

pub fn new() -> Self

Creates an empty registry.

Source

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.

Source

pub fn from_hooks(hooks: Vec<Box<dyn FrameTickHook>>) -> Self

Creates a registry from hooks registered at TickPriority::NORMAL.

Source

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.

Source

pub fn waker(&self) -> FrameWaker

Returns a thread-safe FrameWaker for waking slots from outside tick().

Source

pub fn slot_waker(&self, slot: usize) -> SlotWaker

Returns a thread-safe, zero-alloc SlotWaker bound to slot.

Source

pub fn len(&self) -> usize

Number of live registered hooks.

Source

pub fn is_empty(&self) -> bool

Returns true when no live hooks are registered.

Source

pub fn last_now_ms(&self) -> Option<u64>

Returns the last monotonic timestamp observed by this registry, if any.

Source

pub fn push( &mut self, hook: Box<dyn FrameTickHook>, ) -> (TickHookId, usize, TickDemand)

Registers a hook at TickPriority::NORMAL, returning (id, stable_slot, initial_demand).

Source

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).

Source

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).

Source

pub fn remove(&mut self, id: TickHookId) -> bool

Removes the hook identified by id without shifting any other slot’s index.

Source

pub fn has_pending_wakes(&self) -> bool

Returns true if a FrameWaker woke a live slot since the last drain.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Trait Implementations§

Source§

impl Default for FrameTickRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for FrameTickRegistry

§

impl !Sync for FrameTickRegistry

§

impl !UnwindSafe for FrameTickRegistry

§

impl Forget for FrameTickRegistry

§

impl Freeze for FrameTickRegistry
where *const u8 is !null: Freeze, PhantomData<Option<HookSlot>>: Freeze, PhantomData<usize>: Freeze, PhantomData<OverflowState>: Freeze, *const ArcInner<Atomic<u64>> is !null: Freeze, PhantomData<ArcInner<Atomic<u64>>>: Freeze, *const ArcInner<Atomic<bool>> is !null: Freeze, PhantomData<ArcInner<Atomic<bool>>>: Freeze, *const ArcInner<dyn Fn() + Send + Sync> is !null: Freeze, PhantomData<ArcInner<dyn Fn() + Send + Sync>>: Freeze,

§

impl Move for FrameTickRegistry

§

impl Send for FrameTickRegistry
where RawVecInner: Send, BoxRaw<dyn FrameTickHook>: Send, Arc<Atomic<u64>>: Send, Arc<Atomic<bool>>: Send, Arc<dyn Fn() + Send + Sync>: Send,

§

impl Unpin for FrameTickRegistry
where *const u8 is !null: Unpin, Box<dyn FrameTickHook>: Unpin, Arc<Atomic<u64>>: Unpin, Arc<Atomic<bool>>: Unpin, Arc<dyn Fn() + Send + Sync>: Unpin,

§

impl UnsafeUnpin for FrameTickRegistry
where *const u8 is !null: UnsafeUnpin, PhantomData<Option<HookSlot>>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<OverflowState>: UnsafeUnpin, *const ArcInner<Atomic<u64>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<u64>>>: UnsafeUnpin, *const ArcInner<Atomic<bool>> is !null: UnsafeUnpin, PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin, *const ArcInner<dyn Fn() + Send + Sync> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn() + Send + Sync>>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.