pub struct LinearizabilityTester<ThreadId, RefObj: SequentialSpec> { /* private fields */ }Expand description
This tester captures a potentially concurrent history of operations and
validates that it adheres to a SequentialSpec based on the
linearizability consistency model. This model requires that operations be
applied atomically and that sequenced (non-concurrent) operations are
applied in order.
If you’re not sure whether to pick this or SequentialConsistencyTester, favor
LinearizabilityTester.
§Linearizability
Unlike with sequential consistency, all sequenced (non-concurrent) operations must respect a happens-before relationship, even across threads, which ensures that histories respect “real time” ordering (defined more precisely below). Anomalies are prevented because threads all agree on the viable order of operations. For example, the later read by Thread 2 must read the value of Thread 1’s write (rather than a differing earlier value) since those two operations are not concurrent:
-----------Time------------------------------>
Thread 1: [write invoked... and returns]
Thread 2: [read invoked... and returns]While “real time” is a common way to phrase an implicit total ordering on non-concurrent events spanning threads, a more precise way to think about this is that prior to Thread 2 starting its read, Thread 1 is capable of communicating with Thread 2 indicating that the write finished. This perspective avoids introducing the notion of a shared global time, which is often a misleading perspective when it comes to distributed systems.
The SequentialSpec will imply additional ordering constraints based on semantics specific
to each operation. For example, a value cannot be popped off a stack before it is pushed. It is
then the responsibility of this tester to establish whether a valid total ordering of events
exists under these constraints.
See also: SequentialConsistencyTester.
Implementations§
Source§impl<T: Ord, RefObj: SequentialSpec> LinearizabilityTester<T, RefObj>
impl<T: Ord, RefObj: SequentialSpec> LinearizabilityTester<T, RefObj>
Source§impl<T, RefObj> LinearizabilityTester<T, RefObj>
impl<T, RefObj> LinearizabilityTester<T, RefObj>
Trait Implementations§
Source§impl<ThreadId: Clone, RefObj: Clone + SequentialSpec> Clone for LinearizabilityTester<ThreadId, RefObj>
impl<ThreadId: Clone, RefObj: Clone + SequentialSpec> Clone for LinearizabilityTester<ThreadId, RefObj>
Source§fn clone(&self) -> LinearizabilityTester<ThreadId, RefObj>
fn clone(&self) -> LinearizabilityTester<ThreadId, RefObj>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T, RefObj> ConsistencyTester<T, RefObj> for LinearizabilityTester<T, RefObj>
impl<T, RefObj> ConsistencyTester<T, RefObj> for LinearizabilityTester<T, RefObj>
Source§fn on_invoke(
&mut self,
thread_id: T,
op: RefObj::Op,
) -> Result<&mut Self, String>
fn on_invoke( &mut self, thread_id: T, op: RefObj::Op, ) -> Result<&mut Self, String>
Indicates that a thread invoked an operation. Returns Ok(...) if the
history is valid, even if it is not linearizable.
Source§fn on_return(
&mut self,
thread_id: T,
ret: RefObj::Ret,
) -> Result<&mut Self, String>
fn on_return( &mut self, thread_id: T, ret: RefObj::Ret, ) -> Result<&mut Self, String>
Indicates that a thread’s earlier operation invocation returned. Returns
Ok(...) if the history is valid, even if it is not linearizable.
Source§fn is_consistent(&self) -> bool
fn is_consistent(&self) -> bool
Indicates whether the recorded history is linearizable.
Source§impl<ThreadId: Debug, RefObj: Debug + SequentialSpec> Debug for LinearizabilityTester<ThreadId, RefObj>
impl<ThreadId: Debug, RefObj: Debug + SequentialSpec> Debug for LinearizabilityTester<ThreadId, RefObj>
Source§impl<T: Ord, RefObj> Default for LinearizabilityTester<T, RefObj>where
RefObj: Default + SequentialSpec,
impl<T: Ord, RefObj> Default for LinearizabilityTester<T, RefObj>where
RefObj: Default + SequentialSpec,
Source§impl<ThreadId: Hash, RefObj: Hash + SequentialSpec> Hash for LinearizabilityTester<ThreadId, RefObj>
impl<ThreadId: Hash, RefObj: Hash + SequentialSpec> Hash for LinearizabilityTester<ThreadId, RefObj>
Source§impl<ThreadId: PartialEq, RefObj: PartialEq + SequentialSpec> PartialEq for LinearizabilityTester<ThreadId, RefObj>
impl<ThreadId: PartialEq, RefObj: PartialEq + SequentialSpec> PartialEq for LinearizabilityTester<ThreadId, RefObj>
Source§fn eq(&self, other: &LinearizabilityTester<ThreadId, RefObj>) -> bool
fn eq(&self, other: &LinearizabilityTester<ThreadId, RefObj>) -> bool
self and other values to be equal, and is used by ==.Source§impl<T, RefObj> Serialize for LinearizabilityTester<T, RefObj>
Available on crate feature serde only.
impl<T, RefObj> Serialize for LinearizabilityTester<T, RefObj>
serde only.