Package com.vmlens.api
Class AllInterleavings
- java.lang.Object
-
- com.vmlens.api.AllInterleavings
-
- All Implemented Interfaces:
AutoCloseable
public class AllInterleavings extends Object implements AutoCloseable
The class AllInterleavings let you test all thread interleavings for your test. Enclose your test in a while loop to iterate through all thread interleavings like in the following example:try (AllInterleavings allInterleavings = new AllInterleavings("ConcurrencyTestUniqueId");) { while (allInterleavings.hasNext()) { firstId = 0L; secondId = 0L; UniqueId uniqueId = new UniqueId(); Thread first = new Thread(() -> { firstId = uniqueId.nextId(); }); first.start(); secondId = uniqueId.nextId(); first.join(); assertTrue(firstId != secondId); } }
-
-
Field Summary
Fields Modifier and Type Field Description int
maximumRuns
seeAllInterleavingsBuilder.maximumRuns(int)
for a description and how to set this value.int
maximumSynchronizationActionsPerThread
seeAllInterleavingsBuilder.maximumSynchronizationActionsPerThread(int)
for a description and how to set this value.String
name
The name shown in the interleave report.Class[]
removeAtomicAnnotationFromClassArray
seeAllInterleavingsBuilder.removeAtomicAnnotation(java.lang.Class)
for a description and how to set this value.boolean
showNonVolatileSharedMemoryAccess
seeAllInterleavingsBuilder.showNonVolatileSharedMemoryAccess
for a description and how to set this value.boolean
showStatementsInExecutor
seeAllInterleavingsBuilder.showStatementsInExecutor
for a description and how to set this value.boolean
showStatementsWhenSingleThreaded
seeAllInterleavingsBuilder.showStatementsWhenSingleThreaded
for a description and how to set this value.
-
Constructor Summary
Constructors Constructor Description AllInterleavings(String name)
Creates a new AllInterleavings instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AllInterleavingsBuilder
builder(String name)
Create a newAllInterleavingsBuilder
.void
close()
closes this instanceboolean
hasNext()
Return true if there are still thread interleavings to be executed and select the next thread interleaving.
-
-
-
Field Detail
-
name
public final String name
The name shown in the interleave report.
-
showStatementsWhenSingleThreaded
public final boolean showStatementsWhenSingleThreaded
seeAllInterleavingsBuilder.showStatementsWhenSingleThreaded
for a description and how to set this value.
-
showStatementsInExecutor
public final boolean showStatementsInExecutor
seeAllInterleavingsBuilder.showStatementsInExecutor
for a description and how to set this value.
-
showNonVolatileSharedMemoryAccess
public final boolean showNonVolatileSharedMemoryAccess
seeAllInterleavingsBuilder.showNonVolatileSharedMemoryAccess
for a description and how to set this value.
-
maximumRuns
public final int maximumRuns
seeAllInterleavingsBuilder.maximumRuns(int)
for a description and how to set this value.
-
maximumSynchronizationActionsPerThread
public final int maximumSynchronizationActionsPerThread
seeAllInterleavingsBuilder.maximumSynchronizationActionsPerThread(int)
for a description and how to set this value.
-
removeAtomicAnnotationFromClassArray
public final Class[] removeAtomicAnnotationFromClassArray
seeAllInterleavingsBuilder.removeAtomicAnnotation(java.lang.Class)
for a description and how to set this value.
-
-
Constructor Detail
-
AllInterleavings
public AllInterleavings(String name)
Creates a new AllInterleavings instance. To set non default values useAllInterleavingsBuilder
- Parameters:
name
- The name shown in the interleave report.
-
-
Method Detail
-
builder
public static AllInterleavingsBuilder builder(String name)
Create a newAllInterleavingsBuilder
.- Parameters:
name
- The name shown in the interleave report.- Returns:
- A new
AllInterleavingsBuilder
-
hasNext
public boolean hasNext()
Return true if there are still thread interleavings to be executed and select the next thread interleaving. Otherwise returns false.- Returns:
- true if there are still thread interleavings to be executed otherwise false.
-
close
public void close()
closes this instance- Specified by:
close
in interfaceAutoCloseable
-
-