pub struct WorkerEpoch { /* private fields */ }Expand description
Per-worker epoch state, padded to avoid false sharing.
Each egress worker holds one of these. The TickEngine reads all pinned
fields during reclamation checks; without padding, adjacent workers’
writes would invalidate each other’s cache lines.
128-byte alignment covers both 64-byte (x86) and 128-byte (Apple M-series) cache line sizes.
Implementations§
Source§impl WorkerEpoch
impl WorkerEpoch
Sourcepub fn new(worker_id: u32) -> Self
pub fn new(worker_id: u32) -> Self
Create a new worker epoch in the unpinned state.
last_quiesce_ns is seeded to the current monotonic time so
that the first pin is never misclassified as a stall due to
elapsed process uptime.
Sourcepub fn pin(&self, epoch: u64)
pub fn pin(&self, epoch: u64)
Pin this worker to the given epoch before accessing a snapshot. Records the pin-start timestamp for stall detection.
Sourcepub fn unpin(&self)
pub fn unpin(&self)
Unpin this worker after finishing with the snapshot. Updates the quiescence timestamp.
Sourcepub fn pinned_epoch(&self) -> u64
pub fn pinned_epoch(&self) -> u64
The epoch this worker is pinned to, or EPOCH_UNPINNED.
Sourcepub fn pin_start_ns(&self) -> u64
pub fn pin_start_ns(&self) -> u64
Monotonic nanoseconds when pin() was last called.
Used by the tick thread to measure actual pin hold duration.
Sourcepub fn last_quiesce_ns(&self) -> u64
pub fn last_quiesce_ns(&self) -> u64
Monotonic nanoseconds of the last unpin event.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if cancellation has been requested.
Sourcepub fn request_cancel(&self)
pub fn request_cancel(&self)
Request cancellation (called by TickEngine or shutdown).
Sourcepub fn clear_cancel(&self)
pub fn clear_cancel(&self)
Clear cancellation flag (called when worker is restarted/recycled).