pub struct VClock(SmallVec<[VTimestamp; 4]>);
Expand description
A vector clock for detecting data-races, this is conceptually a map from a vector index (and thus a thread id) to a timestamp. The compare operations require that the invariant that the last element in the internal timestamp slice must not be a 0, hence all zero vector clocks are always represented by the empty slice; and allows for the implementation of compare operations to short circuit the calculation and return the correct result faster, also this means that there is only one unique valid length for each set of vector clock values and hence the PartialEq and Eq derivations are correct.
This means we cannot represent a clock where the last entry is a timestamp-0 read that occurs because of a retag. That’s fine, all it does is risk wrong diagnostics in a extreme corner case.
Tuple Fields§
§0: SmallVec<[VTimestamp; 4]>
Implementations§
Source§impl VClock
impl VClock
Sourcepub(super) fn new_with_index(index: VectorIdx, timestamp: VTimestamp) -> VClock
pub(super) fn new_with_index(index: VectorIdx, timestamp: VTimestamp) -> VClock
Create a new vector-clock containing all zeros except for a value at the given index
Sourcepub(super) fn as_slice(&self) -> &[VTimestamp]
pub(super) fn as_slice(&self) -> &[VTimestamp]
Load the internal timestamp slice in the vector clock
pub(super) fn index_mut(&mut self, index: VectorIdx) -> &mut VTimestamp
Sourcefn get_mut_with_min_len(&mut self, min_len: usize) -> &mut [VTimestamp]
fn get_mut_with_min_len(&mut self, min_len: usize) -> &mut [VTimestamp]
Get a mutable slice to the internal vector with minimum min_len
elements. To preserve invariants, the caller must modify
the min_len
-1 nth element to a non-zero value
Sourcepub(super) fn increment_index(&mut self, idx: VectorIdx, current_span: Span)
pub(super) fn increment_index(&mut self, idx: VectorIdx, current_span: Span)
Increment the vector clock at a known index this will panic if the vector index overflows
pub fn join(&mut self, other: &Self)
Sourcepub(super) fn set_at_index(&mut self, other: &Self, idx: VectorIdx)
pub(super) fn set_at_index(&mut self, other: &Self, idx: VectorIdx)
Set the element at the current index of the vector. May only increase elements.
Sourcepub(super) fn set_zero_vector(&mut self)
pub(super) fn set_zero_vector(&mut self)
Set the vector to the all-zero vector
Trait Implementations§
Source§impl Index<VectorIdx> for VClock
impl Index<VectorIdx> for VClock
Source§type Output = VTimestamp
type Output = VTimestamp
Source§impl PartialOrd for VClock
impl PartialOrd for VClock
impl Eq for VClock
impl StructuralPartialEq for VClock
Auto Trait Implementations§
impl Freeze for VClock
impl RefUnwindSafe for VClock
impl Send for VClock
impl Sync for VClock
impl Unpin for VClock
impl UnwindSafe for VClock
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 64 bytes