Class Schedulers



  • public final class Schedulers
    extends Object
    Static factory methods for creating Schedulers.
    • Method Detail

      • trampoline

        public static Scheduler trampoline()
        Creates and returns a Scheduler that queues work on the current thread to be executed after the current work completes.
        Returns:
        a TrampolineScheduler instance
      • computation

        public static Scheduler computation()
        Creates and returns a Scheduler intended for computational work.

        This can be used for event-loops, processing callbacks and other computational work.

        Do not perform IO-bound work on this scheduler. Use io() instead.

        Unhandled errors will be delivered to the scheduler Thread's Thread.UncaughtExceptionHandler.

        Returns:
        a Scheduler meant for computation-bound work
      • io

        public static Scheduler io()
        Creates and returns a Scheduler intended for IO-bound work.

        The implementation is backed by an Executor thread-pool that will grow as needed.

        This can be used for asynchronously performing blocking IO.

        Do not perform computational work on this scheduler. Use computation() instead.

        Unhandled errors will be delivered to the scheduler Thread's Thread.UncaughtExceptionHandler.

        Returns:
        a Scheduler meant for IO-bound work
      • test

        public static TestScheduler test()
        Creates and returns a TestScheduler, which is useful for debugging. It allows you to test schedules of events by manually advancing the clock at whatever pace you choose.
        Returns:
        a TestScheduler meant for debugging
      • from

        public static Scheduler from(Executor executor)
        Converts an Executor into a new Scheduler instance.
        Parameters:
        executor - the executor to wrap
        Returns:
        the new Scheduler wrapping the Executor