Class RaceTestUtils

java.lang.Object
reactor.test.util.RaceTestUtils

public class RaceTestUtils extends Object
Author:
Stephane Maldini, David Karnok
  • Constructor Details

    • RaceTestUtils

      public RaceTestUtils()
  • Method Details

    • race

      public 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. The method blocks until the given Predicate matches. It performs a BiPredicate test at the end to validate the end result.
      Parameters:
      initial - the initial state
      race - the state-modification Function
      stopRace - the stop condition for the race loop, as a Predicate
      terminate - the validation check, as a BiPredicate
      Returns:
      the result of the terminate check
    • race

      public static void race(Runnable... rs)
      Synchronizes the execution of several Runnables as much as possible to test race conditions. The method blocks until all have run to completion.
      Parameters:
      rs - the runnables to execute
    • race

      public static void race(Runnable r1, Runnable r2)
      Synchronizes the execution of two Runnables 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.
      Parameters:
      r1 - the first runnable to execute
      r2 - the second runnable to execute
      See Also:
    • race

      @Deprecated public static void race(Runnable r1, Runnable r2, Scheduler s)
      Deprecated.
      Use race(Scheduler, Runnable...). To be removed in 3.6.0, at the earliest.
      Synchronizes the execution of two Runnable as much as possible to test race conditions. The method blocks until both have run to completion.
      Parameters:
      s - the Scheduler on which to execute the runnables
      r1 - the first runnable
      r2 - the second runnable
    • race

      public static void race(Scheduler s, Runnable... rs)
      Synchronizes the execution of several Runnables as much as possible to test race conditions. The method blocks until all have run to completion, with a 5s timeout.
      Parameters:
      s - the Scheduler on which to execute the runnables
      rs - the runnables to execute
    • race

      public static void race(int timeoutSeconds, Scheduler s, Runnable... rs)
      Synchronizes the execution of several Runnables 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).
      Parameters:
      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 runnables
      rs - the runnables to execute