Class ABAProblemDetector.AgentSlot
java.lang.Object
se.deversity.asynctest.diagnostics.ABAProblemDetector.AgentSlot
- Enclosing class:
ABAProblemDetector
One
AtomicReference the agent feeds (#817): each woven operation on it runs here, with
its record taken inside the same lock, so the records of one atomic are in the order its
operations ran.
Only woven operations of threads whose test has this detector take the lock; any other code touches the atomic as before. A change that bypasses the lock can hide an A-B-A, never make one: every read and change judged here ran in the order it was recorded, so a reported one really went from the value a thread read, away and back, before that thread's compare-and-set expecting it succeeded.
No history is kept. Each thread's last read is the premise its next compare-and-set is judged against, as on the recording path, and each change updates the other threads' premises as it happens: away from the value they read, then back to it.
- Since:
- 1.12.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceStores into a reference slot and returns what it held, named asABAProblemDetector.AgentSlot.SlotReadnames it.static interfaceReads a reference slot:holderandselectororindexname it.static interfaceStores into a reference slot named asABAProblemDetector.AgentSlot.SlotReadnames it.static interfaceCompares and swaps a reference slot named asABAProblemDetector.AgentSlot.SlotReadnames it. -
Method Summary
Modifier and TypeMethodDescriptionbooleanattemptStamp(AtomicStampedReference<Object> atomic, @Nullable Object expected, int newStamp) PerformsAtomicStampedReference.attemptStamp, recorded, when it took, as a change of the stamp alone.booleancompareAndSet(Object holder, @Nullable Object selector, int index, @Nullable Object expected, @Nullable Object update, ABAProblemDetector.AgentSlot.SlotSwap swap) Performsswap, judged against the calling thread's premise ascompareAndSet(java.lang.Object, java.lang.Object, int, java.lang.Object, java.lang.Object, se.deversity.asynctest.diagnostics.ABAProblemDetector.AgentSlot.SlotSwap)judges it.booleancompareAndSet(AtomicReference<Object> atomic, @Nullable Object expected, @Nullable Object update) PerformsAtomicReference.compareAndSet, judged against the calling thread's premise and recorded, when it swapped, as a change fromexpected.booleancompareAndSetStamped(AtomicStampedReference<Object> atomic, @Nullable Object expected, @Nullable Object update, int expectedStamp, int newStamp, boolean weak) PerformsAtomicStampedReference.compareAndSetorweakCompareAndSet, judged against the calling thread's premise of the pair.@Nullable Objectget(AtomicReference<Object> atomic) PerformsAtomicReference.get, recorded as the calling thread's premise.@Nullable ObjectgetAcquire(AtomicReference<Object> atomic) PerformsAtomicReference.getAcquire, recorded asget(java.util.concurrent.atomic.AtomicReference<java.lang.Object>)records.@Nullable ObjectgetAndSet(Object holder, @Nullable Object selector, int index, @Nullable Object value, ABAProblemDetector.AgentSlot.SlotExchange exchange) Performsexchange, recorded as a change from the value it returns.@Nullable ObjectgetAndSet(AtomicReference<Object> atomic, @Nullable Object value) PerformsAtomicReference.getAndSet, recorded as a change from the value it returns.@Nullable ObjectgetStamped(AtomicStampedReference<Object> atomic, int[] stampHolder) PerformsAtomicStampedReference.get(int[]), recorded as the calling thread's premise: the reference and the stamp read together (#817).@Nullable ObjectPerformsAtomicStampedReference.getReference(), recorded asgetStamped(java.util.concurrent.atomic.AtomicStampedReference<java.lang.Object>, int[])records: the reference with the stamp it held at that moment.voidlazySet(AtomicReference<Object> atomic, @Nullable Object value) PerformsAtomicReference.lazySet, recorded asset(java.util.concurrent.atomic.AtomicReference<java.lang.Object>, java.lang.Object)records.@Nullable Objectread(Object holder, @Nullable Object selector, int index, ABAProblemDetector.AgentSlot.SlotRead read) Performsreadon a slot other than anAtomicReference(#817), recorded as the calling thread's premise, asget(java.util.concurrent.atomic.AtomicReference<java.lang.Object>)records.voidset(AtomicReference<Object> atomic, @Nullable Object value) PerformsAtomicReference.set, recorded as a change from what the atomic held.voidsetRelease(AtomicReference<Object> atomic, @Nullable Object value) PerformsAtomicReference.setRelease, recorded asset(java.util.concurrent.atomic.AtomicReference<java.lang.Object>, java.lang.Object)records.voidsetStamped(AtomicStampedReference<Object> atomic, @Nullable Object value, int stamp) PerformsAtomicStampedReference.set, recorded as a change of the pair.voidstore(Object holder, @Nullable Object selector, int index, @Nullable Object value, ABAProblemDetector.AgentSlot.SlotRead current, ABAProblemDetector.AgentSlot.SlotStore store) Performsstore, recorded as a change from whatcurrentread before it.
-
Method Details
-
read
public @Nullable Object read(Object holder, @Nullable Object selector, int index, ABAProblemDetector.AgentSlot.SlotRead read) Performsreadon a slot other than anAtomicReference(#817), recorded as the calling thread's premise, asget(java.util.concurrent.atomic.AtomicReference<java.lang.Object>)records.- Parameters:
holder- the object or array holding the slotselector- the updater or handle that reaches it, ornullfor an elementindex- the element's index, or 0read- the read, a non-capturing lambda- Returns:
- what the read returned
-
store
public void store(Object holder, @Nullable Object selector, int index, @Nullable Object value, ABAProblemDetector.AgentSlot.SlotRead current, ABAProblemDetector.AgentSlot.SlotStore store) Performsstore, recorded as a change from whatcurrentread before it.- Parameters:
holder- the object or array holding the slotselector- the updater or handle that reaches it, ornullfor an elementindex- the element's index, or 0value- the reference to storecurrent- reads what the slot holds now, a non-capturing lambdastore- the store, a non-capturing lambda
-
compareAndSet
public boolean compareAndSet(Object holder, @Nullable Object selector, int index, @Nullable Object expected, @Nullable Object update, ABAProblemDetector.AgentSlot.SlotSwap swap) Performsswap, judged against the calling thread's premise ascompareAndSet(java.lang.Object, java.lang.Object, int, java.lang.Object, java.lang.Object, se.deversity.asynctest.diagnostics.ABAProblemDetector.AgentSlot.SlotSwap)judges it.- Parameters:
holder- the object or array holding the slotselector- the updater or handle that reaches it, ornullfor an elementindex- the element's index, or 0expected- the reference the slot must holdupdate- the reference to storeswap- the compare-and-set, a non-capturing lambda- Returns:
- whether it swapped
-
getAndSet
public @Nullable Object getAndSet(Object holder, @Nullable Object selector, int index, @Nullable Object value, ABAProblemDetector.AgentSlot.SlotExchange exchange) Performsexchange, recorded as a change from the value it returns.- Parameters:
holder- the object or array holding the slotselector- the updater or handle that reaches it, ornullfor an elementindex- the element's index, or 0value- the reference to storeexchange- the get-and-set, a non-capturing lambda- Returns:
- what the slot held
-
getStamped
PerformsAtomicStampedReference.get(int[]), recorded as the calling thread's premise: the reference and the stamp read together (#817).- Parameters:
atomic- the atomic this slot describesstampHolder- receives the stamp- Returns:
- the reference
-
getStampedReference
PerformsAtomicStampedReference.getReference(), recorded asgetStamped(java.util.concurrent.atomic.AtomicStampedReference<java.lang.Object>, int[])records: the reference with the stamp it held at that moment.- Parameters:
atomic- the atomic this slot describes- Returns:
- the reference
-
setStamped
PerformsAtomicStampedReference.set, recorded as a change of the pair.- Parameters:
atomic- the atomic this slot describesvalue- the reference to storestamp- the stamp to store
-
compareAndSetStamped
public boolean compareAndSetStamped(AtomicStampedReference<Object> atomic, @Nullable Object expected, @Nullable Object update, int expectedStamp, int newStamp, boolean weak) PerformsAtomicStampedReference.compareAndSetorweakCompareAndSet, judged against the calling thread's premise of the pair. With a stamp that only grows, a pair that left never comes back, so a reported one reused a stamp.- Parameters:
atomic- the atomic this slot describesexpected- the reference the atomic must holdupdate- the reference to storeexpectedStamp- the stamp it must holdnewStamp- the stamp to storeweak- whether the call wasweakCompareAndSet- Returns:
- whether it swapped
-
attemptStamp
public boolean attemptStamp(AtomicStampedReference<Object> atomic, @Nullable Object expected, int newStamp) PerformsAtomicStampedReference.attemptStamp, recorded, when it took, as a change of the stamp alone.- Parameters:
atomic- the atomic this slot describesexpected- the reference the atomic must holdnewStamp- the stamp to store- Returns:
- whether the stamp was set
-
get
PerformsAtomicReference.get, recorded as the calling thread's premise.- Parameters:
atomic- the atomic this slot describes- Returns:
- what
getreturned
-
getAcquire
PerformsAtomicReference.getAcquire, recorded asget(java.util.concurrent.atomic.AtomicReference<java.lang.Object>)records.- Parameters:
atomic- the atomic this slot describes- Returns:
- what
getAcquirereturned
-
set
PerformsAtomicReference.set, recorded as a change from what the atomic held.- Parameters:
atomic- the atomic this slot describesvalue- the reference to store
-
lazySet
PerformsAtomicReference.lazySet, recorded asset(java.util.concurrent.atomic.AtomicReference<java.lang.Object>, java.lang.Object)records.- Parameters:
atomic- the atomic this slot describesvalue- the reference to store
-
setRelease
PerformsAtomicReference.setRelease, recorded asset(java.util.concurrent.atomic.AtomicReference<java.lang.Object>, java.lang.Object)records.- Parameters:
atomic- the atomic this slot describesvalue- the reference to store
-
getAndSet
PerformsAtomicReference.getAndSet, recorded as a change from the value it returns.- Parameters:
atomic- the atomic this slot describesvalue- the reference to store- Returns:
- the reference the atomic held
-
compareAndSet
public boolean compareAndSet(AtomicReference<Object> atomic, @Nullable Object expected, @Nullable Object update) PerformsAtomicReference.compareAndSet, judged against the calling thread's premise and recorded, when it swapped, as a change fromexpected. Either way the premise is used up: a retry reads again.- Parameters:
atomic- the atomic this slot describesexpected- the reference the atomic must holdupdate- the reference to store- Returns:
- whether it swapped
-