Class TrampolineScheduler

java.lang.Object
io.reactivex.rxjava3.core.Scheduler
io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler

public final class TrampolineScheduler extends Scheduler
Schedules work on the current thread but does not execute immediately. Work is put in a queue and executed after the current unit of work is completed.
  • Field Details

  • Constructor Details

    • TrampolineScheduler

      TrampolineScheduler()
  • Method Details

    • instance

      public static TrampolineScheduler instance()
    • createWorker

      @NonNull public @NonNull Scheduler.Worker createWorker()
      Description copied from class: Scheduler
      Retrieves or creates a new Scheduler.Worker that represents sequential execution of actions.

      When work is completed, the Worker instance should be released by calling Disposable.dispose() to avoid potential resource leaks in the underlying task-execution scheme.

      Work on a Scheduler.Worker is guaranteed to be sequential and non-overlapping.

      Specified by:
      createWorker in class Scheduler
      Returns:
      a Worker representing a serial queue of actions to be executed
    • scheduleDirect

      @NonNull public @NonNull Disposable scheduleDirect(@NonNull @NonNull Runnable run)
      Description copied from class: Scheduler
      Schedules the given task on this Scheduler without any time delay.

      This method is safe to be called from multiple threads but there are no ordering or non-overlapping guarantees between tasks.

      Overrides:
      scheduleDirect in class Scheduler
      Parameters:
      run - the task to execute
      Returns:
      the Disposable instance that let's one cancel this particular task.
    • scheduleDirect

      @NonNull public @NonNull Disposable scheduleDirect(@NonNull @NonNull Runnable run, long delay, TimeUnit unit)
      Description copied from class: Scheduler
      Schedules the execution of the given task with the given time delay.

      This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.

      Overrides:
      scheduleDirect in class Scheduler
      Parameters:
      run - the task to schedule
      delay - the delay amount, non-positive values indicate non-delayed scheduling
      unit - the unit of measure of the delay amount
      Returns:
      the Disposable that let's one cancel this particular delayed task.