pub struct SharedCursor { /* private fields */ }Expand description
A shared cursor that can be accessed across processes
This implements the disruptor pattern’s cursor concept for multi-process scenarios. Each cursor tracks a sequence position and can be safely shared between processes using shared memory with cache-line padding to prevent false sharing.
Implementations§
Sourcepub fn new_auto(initial_value: i64) -> MultiProcessResult<(Self, String)>
pub fn new_auto(initial_value: i64) -> MultiProcessResult<(Self, String)>
Create a new shared cursor with automatic naming
Sourcepub fn new(name: &str, initial_value: i64) -> MultiProcessResult<Self>
pub fn new(name: &str, initial_value: i64) -> MultiProcessResult<Self>
Create a new shared cursor in a new shared memory segment (legacy method)
Sourcepub fn recreate(name: &str, initial_value: i64) -> MultiProcessResult<Self>
pub fn recreate(name: &str, initial_value: i64) -> MultiProcessResult<Self>
Explicitly recreate a shared cursor by unlinking and creating a fresh segment.
This is intended for crash-restart recovery paths when a stale segment may remain after an unclean shutdown. This operation is destructive for any currently attached process using the same name.
Sourcepub fn attach(name: &str) -> MultiProcessResult<Self>
pub fn attach(name: &str) -> MultiProcessResult<Self>
Attach to an existing shared cursor in an existing shared memory segment
Sourcepub fn new_or_attach(name: &str, initial_value: i64) -> MultiProcessResult<Self>
pub fn new_or_attach(name: &str, initial_value: i64) -> MultiProcessResult<Self>
Create a new shared cursor, or attach to existing one if it already exists
Sourcepub fn is_owner(&self) -> bool
pub fn is_owner(&self) -> bool
Return whether this mapping currently owns unlink responsibility.
Sourcepub fn set_owner(&mut self, is_owner: bool) -> bool
pub fn set_owner(&mut self, is_owner: bool) -> bool
Transfer or release ownership of the underlying shared-memory name.
Consumer sequence cursors use this to become persistent restart anchors: the first attaching consumer may create the cursor segment, but it must not unlink that name when the process exits, or subsequent restarts would reset the logical consumer position back to the initial value.
Sourcepub fn compare_exchange(
&self,
current: i64,
new: i64,
success: Ordering,
failure: Ordering,
) -> Result<i64, i64>
pub fn compare_exchange( &self, current: i64, new: i64, success: Ordering, failure: Ordering, ) -> Result<i64, i64>
Compare and swap