public class RaceTestUtils extends Object
Constructor and Description |
---|
RaceTestUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
race(int timeoutSeconds,
Scheduler s,
Runnable... rs)
Synchronizes the execution of several
Runnable s as much as possible
to test race conditions. |
static void |
race(Runnable... rs)
Synchronizes the execution of several
Runnable s as much as possible
to test race conditions. |
static void |
race(Runnable r1,
Runnable r2)
Synchronizes the execution of two
Runnable s as much as possible
to test race conditions. |
static void |
race(Runnable r1,
Runnable r2,
Scheduler s)
Deprecated.
Use
race(Scheduler, Runnable...) . To be removed in 3.6.0, at the earliest. |
static void |
race(Scheduler s,
Runnable... rs)
Synchronizes the execution of several
Runnable s as much as possible
to test race conditions. |
static <T> boolean |
race(T initial,
Function<? super T,? extends T> race,
Predicate<? super T> stopRace,
BiPredicate<? super T,? super T> terminate)
Synchronizes the execution of two concurrent state modifications as much as
possible to test race conditions.
|
public static <T> boolean race(T initial, Function<? super T,? extends T> race, Predicate<? super T> stopRace, BiPredicate<? super T,? super T> terminate)
Predicate
matches. It performs a BiPredicate
test at the end to validate the end
result.initial
- the initial staterace
- the state-modification Function
stopRace
- the stop condition for the race loop, as a Predicate
terminate
- the validation check, as a BiPredicate
terminate
checkpublic static void race(Runnable... rs)
Runnable
s as much as possible
to test race conditions. The method blocks until all have run to completion.rs
- the runnables to executepublic static void race(Runnable r1, Runnable r2)
Runnable
s as much as possible
to test race conditions. The method blocks until both have run to completion.
Kept for binary compatibility, see the varargs variant.r1
- the first runnable to executer2
- the second runnable to executerace(Runnable...)
@Deprecated public static void race(Runnable r1, Runnable r2, Scheduler s)
race(Scheduler, Runnable...)
. To be removed in 3.6.0, at the earliest.Runnable
as much as possible
to test race conditions. The method blocks until both have run to completion.s
- the Scheduler
on which to execute the runnablesr1
- the first runnabler2
- the second runnablepublic static void race(Scheduler s, Runnable... rs)
Runnable
s as much as possible
to test race conditions. The method blocks until all have run to completion,
with a 5s timeout.s
- the Scheduler
on which to execute the runnablesrs
- the runnables to executepublic static void race(int timeoutSeconds, Scheduler s, Runnable... rs)
Runnable
s as much as possible
to test race conditions. The method blocks until all have run to completion,
with a configurable timeout (allowing for debugging sessions to use a larger timeout).timeoutSeconds
- the number of seconds after which the race is considered timed out. intended for debugging purposes.s
- the Scheduler
on which to execute the runnablesrs
- the runnables to execute