pub struct VMClockShmWriter { /* private fields */ }Expand description
Writer to the VMClock shared memory segment.
This writer is expected to be used by a single process writing to a given path. The file written to is memory mapped by the writer and many (read-only) readers. Updates to the memory segment are applied in a lock-free manner, using a rolling seq_count number to protect the update section.
Implementations§
Source§impl VMClockShmWriter
impl VMClockShmWriter
Sourcepub fn new(path: &Path) -> Result<VMClockShmWriter>
pub fn new(path: &Path) -> Result<VMClockShmWriter>
Create a new VMClockShmWriter referencing the memory segment to write VMClockShmBody data to.
There are several cases to consider:
- The file backing the memory segment does not exist, or the content is corrupted/wrong. This is a cold start-like scenario, creating a fresh memory mapped file.
- The file backing the memory segment already exist and is valid. This may be that the process using this writer has restarted, but clients may still be using the existing values. Here, we want to load the existing memory segment, and continue as if nothing happened. That’s a warm reboot-like scenario.
- A variation of 2., but where the layout is being changed (a version bump). This is analog to a cold boot.
TODO: implement scenario 3 once the readers support a version bump.
Trait Implementations§
Source§impl Debug for VMClockShmWriter
impl Debug for VMClockShmWriter
Source§impl Drop for VMClockShmWriter
impl Drop for VMClockShmWriter
Source§impl VMClockShmWrite for VMClockShmWriter
impl VMClockShmWrite for VMClockShmWriter
Source§fn write(&mut self, vmclock_shm_body: &VMClockShmBody)
fn write(&mut self, vmclock_shm_body: &VMClockShmBody)
Update the clock error bound data in the memory segment.
This function implements the lock-free mechanism that lets the writer update the memory segment shared with many readers. The seq_count number is set to an odd number before the update and an even number when successfully completed.