Skip to main content

SharedFenceClock

Struct SharedFenceClock 

Source
pub struct SharedFenceClock { /* private fields */ }

Implementations§

Source§

impl SharedFenceClock

Source

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

Obtain the clock table at path, initializing an empty one if the path does not yet exist and attaching to it if it does. Attaching leaves the registered slots and the global fence in place; a region built with a different capacity is a LayoutMismatch. reset reinitializes.

Source

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

Truncate the clock table at path and initialize an empty one, unregistering every slot a live peer holds. For a caller that knows it owns the path.

Source

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

Source

pub fn capacity(&self) -> usize

Source

pub fn shared_clock_us(&self) -> u64

Current shared cross-process cached wall clock (microseconds). This is the freshest cache any process on the host has published to the MMF; it advances when any process ticks. One atomic load.

Source

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

Register the calling process. CAS-claims the first empty slot; returns slot index.

Source

pub fn unregister(&self, idx: usize)

Release a slot so another process can claim it.

Source

pub fn tick(&self, idx: usize) -> Hlc

Local internal-event HLC tick. Advances this slot’s HLC per the standard rules.

Source

pub fn merge(&self, idx: usize, remote: Hlc) -> Hlc

Merge a remote HLC (e.g., received in a message) into this slot. Returns the new local HLC.

Source

pub fn get_local(&self, idx: usize) -> Hlc

Read this slot’s current HLC.

Source

pub fn compute_global_fence(&self) -> Hlc

Walk all slots and compute max(slot.hlc) across all non-vacant slots. This is the global fence: the timestamp at which all peers’ events are observable.

Source

pub fn publish_global_fence(&self) -> Hlc

Publish the computed global fence to the header so other processes can read it via read_global_fence at O(1).

Source

pub fn read_global_fence(&self) -> Hlc

Read the most-recently-published global fence (O(1); set by a publisher process / coordinator).

Source

pub fn slot_snapshot(&self, idx: usize) -> Option<HlcSlotSnapshot>

Snapshot a specific slot (returns None when vacant).

Source

pub fn fence_epoch(&self) -> u64

Total fence-publish epochs (counter bumped by publish_global_fence).

Source

pub fn flush(&self) -> Result<(), FenceClockError>

Source

pub fn flush_async(&self) -> Result<(), FenceClockError>

Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).

Trait Implementations§

Source§

impl AdaptiveInstance for SharedFenceClock

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 SharedFenceClock

Source§

impl Sync for SharedFenceClock

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.