Skip to main content

HeartbeatTable

Struct HeartbeatTable 

Source
pub struct HeartbeatTable { /* private fields */ }
Expand description

Cross-process heartbeat registry. Each process opens this and reserves one slot via HeartbeatTable::register.

Implementations§

Source§

impl HeartbeatTable

Source

pub fn create( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, HeartbeatError>

Obtain the table at path, initializing it only when the path does not yet exist. Attaching leaves live registrations in place; a table built with a different capacity is a LayoutMismatch. Use reset to deliberately clear it.

Source

pub fn reset( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, HeartbeatError>

Reinitialise the table at path, discarding every live registration. For a caller that knows it owns the path.

Source

pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, HeartbeatError>

Source

pub fn capacity(&self) -> usize

Source

pub fn header(&self) -> &HeartbeatHeader

Source

pub fn register(&self, pid: u32) -> Result<usize, HeartbeatError>

Register the current process. Returns the slot index. CAS-claim of the first empty slot.

Source

pub fn unregister(&self, idx: usize)

Release the slot at idx. Call before process exit.

Source

pub fn beat(&self, idx: usize)

Heartbeat: advance this slot’s last_seen_epoch to match the global epoch. Call once per scan tick.

Source

pub fn tick_global_epoch(&self) -> u64

Advance the global epoch. Watchdog calls this once per scan interval. Returns the new epoch value.

Source

pub fn global_epoch(&self) -> u64

Source

pub fn mark_in_flight(&self, slot_idx: usize, bit: u8)

Mark a work unit as in-flight for slot_idx.

Source

pub fn clear_in_flight(&self, slot_idx: usize, bit: u8)

Source

pub fn snapshot(&self, idx: usize) -> Option<HeartbeatSnapshot>

Snapshot a slot via SeqLock retry. Returns None if the slot is vacant.

Trait Implementations§

Source§

impl AdaptiveInstance for HeartbeatTable

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for HeartbeatTable

Source§

impl Sync for HeartbeatTable

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.