Struct miri::concurrency::vector_clock::VClock
source · 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.
Tuple Fields§
§0: SmallVec<[VTimestamp; 4]>
Implementations§
source§impl 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, current_span: Span)
pub 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 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§
source§impl PartialEq<VClock> for VClock
impl PartialEq<VClock> for VClock
source§impl PartialOrd<VClock> for VClock
impl PartialOrd<VClock> for VClock
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§
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
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