pub struct VersionSet { /* private fields */ }Expand description
VersionSet manages the current SuperVersion and provides atomic updates
This is the entry point for all metadata access. Readers call get() to
acquire the current SuperVersion, writers call install() to atomically
swap in a new version.
§Thread Safety
get(): Lock-free (atomic load)install(): Serialized through internal mutex (writers must coordinate)
Multiple readers can proceed in parallel with zero synchronization. Writers are serialized to ensure consistent version progression.
Implementations§
Source§impl VersionSet
impl VersionSet
Sourcepub fn get(&self) -> Guard<Arc<SuperVersion>>
pub fn get(&self) -> Guard<Arc<SuperVersion>>
Get current SuperVersion (lock-free)
This is the hot path for reads. Returns a Guard that holds an Arc to the current SuperVersion. The Guard can be dereferenced to access the SuperVersion.
§Performance
- Time: O(1) atomic load
- No locks acquired
- No memory allocation
Sourcepub fn get_arc(&self) -> Arc<SuperVersion>
pub fn get_arc(&self) -> Arc<SuperVersion>
Get current SuperVersion as owned Arc
Use this when you need to hold the SuperVersion across await points or store it for later use.
Sourcepub fn install(&self, new_version: SuperVersion)
pub fn install(&self, new_version: SuperVersion)
Install a new SuperVersion (serialized)
This atomically swaps the new version into place. The old version remains valid for any readers that acquired it before the swap.
§Safety
Only one writer should call this at a time. Use with_write_lock()
to serialize concurrent updates.
Sourcepub fn with_write_lock<F>(&self, f: F) -> SuperVersion
pub fn with_write_lock<F>(&self, f: F) -> SuperVersion
Execute a function with exclusive write access
Use this to ensure atomic read-modify-write operations on the version set. The function receives the current SuperVersion and should return the new SuperVersion to install.
Sourcepub fn register_snapshot(&self, seqno: u64) -> u64
pub fn register_snapshot(&self, seqno: u64) -> u64
Register a snapshot at the given sequence number
Returns the snapshot sequence number for later release.
Sourcepub fn release_snapshot(&self, seqno: u64)
pub fn release_snapshot(&self, seqno: u64)
Release a snapshot
Sourcepub fn min_preserved_seqno(&self) -> u64
pub fn min_preserved_seqno(&self) -> u64
Get minimum sequence number that must be preserved
Returns the oldest snapshot sequence number, or the current version’s min_snapshot_seqno if no snapshots are active.
Sourcepub fn update_min_snapshot_seqno(&self)
pub fn update_min_snapshot_seqno(&self)
Update min_snapshot_seqno based on active snapshots
Sourcepub fn version_number(&self) -> u64
pub fn version_number(&self) -> u64
Get current version number
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for VersionSet
impl !RefUnwindSafe for VersionSet
impl Send for VersionSet
impl Sync for VersionSet
impl Unpin for VersionSet
impl !UnwindSafe for VersionSet
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
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>
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>
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