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
Tuple Fields
0: SmallVec<[VTimestamp; 4]>Implementations
sourceimpl VClock
impl VClock
sourcepub fn new_with_index(index: VectorIdx, timestamp: VTimestamp) -> VClock
pub 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 fn as_slice(&self) -> &[VTimestamp]
pub fn as_slice(&self) -> &[VTimestamp]
Load the internal timestamp slice in the vector clock
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 this vector must modify
the min_len-1 nth element to a non-zero value
sourcepub fn increment_index(&mut self, idx: VectorIdx)
pub fn increment_index(&mut self, idx: VectorIdx)
Increment the vector clock at a known index this will panic if the vector index overflows
pub fn join(&mut self, other: &Self)
sourcepub fn set_at_index(&mut self, other: &Self, idx: VectorIdx)
pub fn set_at_index(&mut self, other: &Self, idx: VectorIdx)
Set the element at the current index of the vector
sourcepub fn set_zero_vector(&mut self)
pub fn set_zero_vector(&mut self)
Set the vector to the all-zero vector
sourcepub fn is_zero_vector(&self) -> bool
pub fn is_zero_vector(&self) -> bool
Return if this vector is the all-zero vector
Trait Implementations
sourceimpl PartialOrd<VClock> for VClock
impl PartialOrd<VClock> for VClock
sourcefn partial_cmp(&self, other: &VClock) -> Option<Ordering>
fn partial_cmp(&self, other: &VClock) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
sourcefn lt(&self, other: &VClock) -> bool
fn lt(&self, other: &VClock) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
sourcefn le(&self, other: &VClock) -> bool
fn le(&self, other: &VClock) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Eq for VClock
impl StructuralEq for VClock
impl StructuralPartialEq for VClock
Auto Trait Implementations
impl RefUnwindSafe for VClock
impl Send for VClock
impl Sync for VClock
impl Unpin for VClock
impl UnwindSafe for VClock
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
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: 24 bytes