pub struct MmapSnapshot { /* private fields */ }Expand description
File-backed, cross-process seqlock snapshot.
Only the seqlock header and the SnapshotData block are shared; the layout
is the #[repr(C)] prefix of SharedSnapshot, so the two are
byte-compatible. The seqlock protocol (odd/even sequence, retry on torn
reads) is identical across processes — the OS guarantees coherence of
MAP_SHARED pages.
Implementations§
Source§impl MmapSnapshot
impl MmapSnapshot
Sourcepub fn write(&self, data: &SnapshotData) -> Result<(), String>
pub fn write(&self, data: &SnapshotData) -> Result<(), String>
Publish a full SnapshotData under the seqlock.
Sourcepub fn begin_write(&self) -> Result<u64, String>
pub fn begin_write(&self) -> Result<u64, String>
Begin an in-place write; returns the token for end_write.
Sourcepub unsafe fn data_mut(&self) -> &mut SnapshotData
pub unsafe fn data_mut(&self) -> &mut SnapshotData
Exclusive &mut access to the data block while the seqlock is held.
§Safety
Caller must hold the seqlock (begin_write, not yet end_write).
Sourcepub fn read(&self) -> Option<SnapshotData>
pub fn read(&self) -> Option<SnapshotData>
Read the snapshot; None after SNAPSHOT_MAX_RETRIES torn reads or
while the file is not initialized.
Trait Implementations§
impl Send for MmapSnapshot
Available on non-WebAssembly only.
impl Sync for MmapSnapshot
Available on non-WebAssembly only.
Auto Trait Implementations§
impl !Freeze for MmapSnapshot
impl !RefUnwindSafe for MmapSnapshot
impl Unpin for MmapSnapshot
impl UnsafeUnpin for MmapSnapshot
impl UnwindSafe for MmapSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more