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
impl HeartbeatTable
Sourcepub fn create(
path: impl AsRef<Path>,
capacity: usize,
) -> Result<Self, HeartbeatError>
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.
Sourcepub fn reset(
path: impl AsRef<Path>,
capacity: usize,
) -> Result<Self, HeartbeatError>
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.
pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, HeartbeatError>
pub fn capacity(&self) -> usize
pub fn header(&self) -> &HeartbeatHeader
Sourcepub fn register(&self, pid: u32) -> Result<usize, HeartbeatError>
pub fn register(&self, pid: u32) -> Result<usize, HeartbeatError>
Register the current process. Returns the slot index. CAS-claim of the first empty slot.
Sourcepub fn unregister(&self, idx: usize)
pub fn unregister(&self, idx: usize)
Release the slot at idx. Call before process exit.
Sourcepub fn beat(&self, idx: usize)
pub fn beat(&self, idx: usize)
Heartbeat: advance this slot’s last_seen_epoch to match the
global epoch. Call once per scan tick.
Sourcepub fn tick_global_epoch(&self) -> u64
pub fn tick_global_epoch(&self) -> u64
Advance the global epoch. Watchdog calls this once per scan interval. Returns the new epoch value.
pub fn global_epoch(&self) -> u64
Sourcepub fn mark_in_flight(&self, slot_idx: usize, bit: u8)
pub fn mark_in_flight(&self, slot_idx: usize, bit: u8)
Mark a work unit as in-flight for slot_idx.
pub fn clear_in_flight(&self, slot_idx: usize, bit: u8)
Sourcepub fn snapshot(&self, idx: usize) -> Option<HeartbeatSnapshot>
pub fn snapshot(&self, idx: usize) -> Option<HeartbeatSnapshot>
Snapshot a slot via SeqLock retry. Returns None if the slot
is vacant.