pub struct SequentialConsistencyTester<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
sequential consistency model. This model requires that operations be
applied atomically and that operations within a thread are sequential
(they have a total order within the thread).
If you’re not sure whether to pick this or LinearizabilityTester, favor
LinearizabilityTester.
§Sequential Consistency
Unlike with linearizability, there is no intrinsic order of operations across threads, even if they are fully sequenced in “real-time” (defined more precisely below). Anomalies are therefore possible as threads do not necessarily agree on viable orders of operations. For example, the later read by Thread 2 in this diagram is allowed to return the value prior to Thread 1’s write even though the operations are seemingly 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 the checker to establish whether a valid total ordering of events
exists under these constraints.
See also: LinearizabilityTester.
Implementations§
Source§impl<T: Ord, RefObj: SequentialSpec> SequentialConsistencyTester<T, RefObj>
impl<T: Ord, RefObj: SequentialSpec> SequentialConsistencyTester<T, RefObj>
Source§impl<T, RefObj> SequentialConsistencyTester<T, RefObj>
impl<T, RefObj> SequentialConsistencyTester<T, RefObj>
Trait Implementations§
Source§impl<ThreadId: Clone, RefObj: Clone + SequentialSpec> Clone for SequentialConsistencyTester<ThreadId, RefObj>
impl<ThreadId: Clone, RefObj: Clone + SequentialSpec> Clone for SequentialConsistencyTester<ThreadId, RefObj>
Source§fn clone(&self) -> SequentialConsistencyTester<ThreadId, RefObj>
fn clone(&self) -> SequentialConsistencyTester<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 SequentialConsistencyTester<T, RefObj>
impl<T, RefObj> ConsistencyTester<T, RefObj> for SequentialConsistencyTester<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 sequentially consistent.
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 sequentially
consistent.
Source§fn is_consistent(&self) -> bool
fn is_consistent(&self) -> bool
Indicates whether the recorded history is sequentially consistent.
Source§impl<ThreadId: Debug, RefObj: Debug + SequentialSpec> Debug for SequentialConsistencyTester<ThreadId, RefObj>
impl<ThreadId: Debug, RefObj: Debug + SequentialSpec> Debug for SequentialConsistencyTester<ThreadId, RefObj>
Source§impl<T: Ord, RefObj> Default for SequentialConsistencyTester<T, RefObj>where
RefObj: Default + SequentialSpec,
impl<T: Ord, RefObj> Default for SequentialConsistencyTester<T, RefObj>where
RefObj: Default + SequentialSpec,
Source§impl<ThreadId: Hash, RefObj: Hash + SequentialSpec> Hash for SequentialConsistencyTester<ThreadId, RefObj>
impl<ThreadId: Hash, RefObj: Hash + SequentialSpec> Hash for SequentialConsistencyTester<ThreadId, RefObj>
Source§impl<ThreadId: PartialEq, RefObj: PartialEq + SequentialSpec> PartialEq for SequentialConsistencyTester<ThreadId, RefObj>
impl<ThreadId: PartialEq, RefObj: PartialEq + SequentialSpec> PartialEq for SequentialConsistencyTester<ThreadId, RefObj>
Source§fn eq(&self, other: &SequentialConsistencyTester<ThreadId, RefObj>) -> bool
fn eq(&self, other: &SequentialConsistencyTester<ThreadId, RefObj>) -> bool
self and other values to be equal, and is used by ==.Source§impl<T, RefObj> Serialize for SequentialConsistencyTester<T, RefObj>
Available on crate feature serde only.
impl<T, RefObj> Serialize for SequentialConsistencyTester<T, RefObj>
serde only.