Interface Scheduler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Scheduler
A source of delays useful for scheduling message delivery in tests.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Scheduler
    Returns a scheduler that delays messages by a random amount between 80ms and 120ms.
    static Scheduler
    Returns a scheduler that delays messages by a random amount between 80ms and 120ms using the given random number generator.
    static Scheduler
    randomScheduler(Random rand, long base, long jitter)
    Returns a scheduler that delays messages by a random amount between base and base + jitter at millisecond precision using the given random number generator.
    Returns the delay until the value should be scheduled.
  • Method Details

    • defaultScheduler

      static Scheduler defaultScheduler()
      Returns a scheduler that delays messages by a random amount between 80ms and 120ms.
      Returns:
      the scheduler
    • defaultScheduler

      static Scheduler defaultScheduler(Random rand)
      Returns a scheduler that delays messages by a random amount between 80ms and 120ms using the given random number generator.
      Returns:
      the scheduler
    • randomScheduler

      static Scheduler randomScheduler(Random rand, long base, long jitter)
      Returns a scheduler that delays messages by a random amount between base and base + jitter at millisecond precision using the given random number generator.
      Returns:
      the scheduler
    • schedule

      Duration schedule()
      Returns the delay until the value should be scheduled. Must not be negative.
      Returns:
      the non-negative delay until the value should be scheduled