Class RxJavaPlugins

java.lang.Object
io.reactivex.rxjava4.plugins.RxJavaPlugins

public final class RxJavaPlugins extends Object
Utility class to inject handlers to certain standard RxJava operations.
  • Method Details

    • lockdown

      public static void lockdown()
      Prevents changing the plugins from then on.

      This allows container-like environments to prevent clients messing with plugins.

    • isLockdown

      public static boolean isLockdown()
      Returns true if the plugins were locked down.
      Returns:
      true if the plugins were locked down
    • setFailOnNonBlockingScheduler

      public static void setFailOnNonBlockingScheduler(boolean enable)
      Enables or disables the blockingX operators to fail with an IllegalStateException on a non-blocking scheduler such as computation or single.

      History: 2.0.5 - experimental

      Parameters:
      enable - enable or disable the feature
      Since:
      2.1
    • isFailOnNonBlockingScheduler

      public static boolean isFailOnNonBlockingScheduler()
      Returns true if the blockingX operators fail with an IllegalStateException on a non-blocking scheduler such as computation or single.

      History: 2.0.5 - experimental

      Returns:
      true if the blockingX operators fail on a non-blocking scheduler
      Since:
      2.1
    • getComputationSchedulerHandler

      @Nullable public static @Nullable Function<? super Scheduler, ? extends Scheduler> getComputationSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getErrorHandler

      @Nullable public static @Nullable Consumer<? super Throwable> getErrorHandler()
      Returns the a hook consumer.
      Returns:
      the hook consumer, may be null
    • getInitComputationSchedulerHandler

      @Nullable public static @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> getInitComputationSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getInitCachedSchedulerHandler

      @Nullable public static @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> getInitCachedSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getInitVirtualSchedulerHandler

      @Nullable public static @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> getInitVirtualSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getInitNewThreadSchedulerHandler

      @Nullable public static @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> getInitNewThreadSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getInitSingleSchedulerHandler

      @Nullable public static @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> getInitSingleSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getCachedSchedulerHandler

      @Nullable public static @Nullable Function<? super Scheduler, ? extends Scheduler> getCachedSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getVirtualSchedulerHandler

      @Nullable public static @Nullable Function<? super Scheduler, ? extends Scheduler> getVirtualSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getNewThreadSchedulerHandler

      @Nullable public static @Nullable Function<? super Scheduler, ? extends Scheduler> getNewThreadSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getScheduleHandler

      @Nullable public static @Nullable Function<? super Runnable, ? extends Runnable> getScheduleHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getSingleSchedulerHandler

      @Nullable public static @Nullable Function<? super Scheduler, ? extends Scheduler> getSingleSchedulerHandler()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • initComputationScheduler

      @NonNull public static @NonNull Scheduler initComputationScheduler(@NonNull @NonNull Supplier<Scheduler> defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - a Supplier which returns the hook's input value
      Returns:
      the value returned by the hook, not null
      Throws:
      NullPointerException - if the supplier parameter or its result are null
    • initCachedScheduler

      @NonNull public static @NonNull Scheduler initCachedScheduler(@NonNull @NonNull Supplier<Scheduler> defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - a Supplier which returns the hook's input value
      Returns:
      the value returned by the hook, not null
      Throws:
      NullPointerException - if the supplier parameter or its result are null
    • initVirtualScheduler

      @NonNull public static @NonNull Scheduler initVirtualScheduler(@NonNull @NonNull Supplier<Scheduler> defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - a Supplier which returns the hook's input value
      Returns:
      the value returned by the hook, not null
      Throws:
      NullPointerException - if the supplier parameter or its result are null
    • initNewThreadScheduler

      @NonNull public static @NonNull Scheduler initNewThreadScheduler(@NonNull @NonNull Supplier<Scheduler> defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - a Supplier which returns the hook's input value
      Returns:
      the value returned by the hook, not null
      Throws:
      NullPointerException - if the supplier parameter or its result are null
    • initSingleScheduler

      @NonNull public static @NonNull Scheduler initSingleScheduler(@NonNull @NonNull Supplier<Scheduler> defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - a Supplier which returns the hook's input value
      Returns:
      the value returned by the hook, not null
      Throws:
      NullPointerException - if the supplier parameter or its result are null
    • onComputationScheduler

      @NonNull public static @NonNull Scheduler onComputationScheduler(@NonNull @NonNull Scheduler defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - the hook's input value
      Returns:
      the value returned by the hook
    • onError

      public static void onError(@NonNull @NonNull Throwable error)
      Called when an undeliverable error occurs.

      Undeliverable errors are those Observer.onError() invocations that are not allowed to happen on the given consumer type (Observer, Subscriber, etc.) due to protocol restrictions because the consumer has either disposed/cancelled its Disposable/Subscription or has already terminated with an onError() or onComplete() signal.

      By default, this global error handler prints the stacktrace via Throwable.printStackTrace() and calls Thread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable) on the current thread.

      Note that on some platforms, the platform runtime terminates the current application with an error if such uncaught exceptions happen. In this case, it is recommended the application installs a global error handler via the setErrorHandler(Consumer) plugin method.

      Parameters:
      error - the error to report
      See Also:
    • onCachedScheduler

      @NonNull public static @NonNull Scheduler onCachedScheduler(@NonNull @NonNull Scheduler defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - the hook's input value
      Returns:
      the value returned by the hook
    • onVirtualScheduler

      @NonNull public static @NonNull Scheduler onVirtualScheduler(@NonNull @NonNull Scheduler defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - the hook's input value
      Returns:
      the value returned by the hook
    • onNewThreadScheduler

      @NonNull public static @NonNull Scheduler onNewThreadScheduler(@NonNull @NonNull Scheduler defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - the hook's input value
      Returns:
      the value returned by the hook
    • onSchedule

      @NonNull public static @NonNull Runnable onSchedule(@NonNull @NonNull Runnable run)
      Called when a task is scheduled.
      Parameters:
      run - the runnable instance
      Returns:
      the replacement runnable
    • onSingleScheduler

      @NonNull public static @NonNull Scheduler onSingleScheduler(@NonNull @NonNull Scheduler defaultScheduler)
      Calls the associated hook function.
      Parameters:
      defaultScheduler - the hook's input value
      Returns:
      the value returned by the hook
    • reset

      public static void reset()
      Removes all handlers and resets to default behavior.
    • setComputationSchedulerHandler

      public static void setComputationSchedulerHandler(@Nullable @Nullable Function<? super Scheduler, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • setErrorHandler

      public static void setErrorHandler(@Nullable @Nullable Consumer<? super Throwable> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • setInitComputationSchedulerHandler

      public static void setInitComputationSchedulerHandler(@Nullable @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed, but the function may not return null
    • setInitCachedSchedulerHandler

      public static void setInitCachedSchedulerHandler(@Nullable @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed, but the function may not return null
    • setInitVirtualSchedulerHandler

      public static void setInitVirtualSchedulerHandler(@Nullable @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed, but the function may not return null
    • setInitNewThreadSchedulerHandler

      public static void setInitNewThreadSchedulerHandler(@Nullable @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed, but the function may not return null
    • setInitSingleSchedulerHandler

      public static void setInitSingleSchedulerHandler(@Nullable @Nullable Function<? super Supplier<Scheduler>, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed, but the function may not return null
    • setCachedSchedulerHandler

      public static void setCachedSchedulerHandler(@Nullable @Nullable Function<? super Scheduler, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • setVirtualSchedulerHandler

      public static void setVirtualSchedulerHandler(@Nullable @Nullable Function<? super Scheduler, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • setNewThreadSchedulerHandler

      public static void setNewThreadSchedulerHandler(@Nullable @Nullable Function<? super Scheduler, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • setScheduleHandler

      public static void setScheduleHandler(@Nullable @Nullable Function<? super Runnable, ? extends Runnable> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • setSingleSchedulerHandler

      public static void setSingleSchedulerHandler(@Nullable @Nullable Function<? super Scheduler, ? extends Scheduler> handler)
      Sets the specific hook function.
      Parameters:
      handler - the hook function to set, null allowed
    • getOnCompletableAssembly

      @Nullable public static @Nullable Function<? super Completable, ? extends Completable> getOnCompletableAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnCompletableSubscribe

      @Nullable public static @Nullable BiFunction<? super Completable, @NonNull ? super CompletableObserver, @NonNull ? extends CompletableObserver> getOnCompletableSubscribe()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnFlowableAssembly

      @Nullable public static @Nullable Function<? super Flowable, ? extends Flowable> getOnFlowableAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnConnectableFlowableAssembly

      @Nullable public static @Nullable Function<? super ConnectableFlowable, ? extends ConnectableFlowable> getOnConnectableFlowableAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnFlowableSubscribe

      @Nullable public static @Nullable BiFunction<? super Flowable, @NonNull ? super Flow.Subscriber, @NonNull ? extends Flow.Subscriber> getOnFlowableSubscribe()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnMaybeSubscribe

      @Nullable public static @Nullable BiFunction<? super Maybe, @NonNull ? super MaybeObserver, @NonNull ? extends MaybeObserver> getOnMaybeSubscribe()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnMaybeAssembly

      @Nullable public static @Nullable Function<? super Maybe, ? extends Maybe> getOnMaybeAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnSingleAssembly

      @Nullable public static @Nullable Function<? super Single, ? extends Single> getOnSingleAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnSingleSubscribe

      @Nullable public static @Nullable BiFunction<? super Single, @NonNull ? super SingleObserver, @NonNull ? extends SingleObserver> getOnSingleSubscribe()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnObservableAssembly

      @Nullable public static @Nullable Function<? super Observable, ? extends Observable> getOnObservableAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnConnectableObservableAssembly

      @Nullable public static @Nullable Function<? super ConnectableObservable, ? extends ConnectableObservable> getOnConnectableObservableAssembly()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • getOnObservableSubscribe

      @Nullable public static @Nullable BiFunction<? super Observable, @NonNull ? super Observer, @NonNull ? extends Observer> getOnObservableSubscribe()
      Returns the current hook function.
      Returns:
      the hook function, may be null
    • setOnCompletableAssembly

      public static void setOnCompletableAssembly(@Nullable @Nullable Function<? super Completable, ? extends Completable> onCompletableAssembly)
      Sets the specific hook function.
      Parameters:
      onCompletableAssembly - the hook function to set, null allowed
    • setOnCompletableSubscribe

      public static void setOnCompletableSubscribe(@Nullable @Nullable BiFunction<? super Completable, @NonNull ? super CompletableObserver, @NonNull ? extends CompletableObserver> onCompletableSubscribe)
      Sets the specific hook function.
      Parameters:
      onCompletableSubscribe - the hook function to set, null allowed
    • setOnFlowableAssembly

      public static void setOnFlowableAssembly(@Nullable @Nullable Function<? super Flowable, ? extends Flowable> onFlowableAssembly)
      Sets the specific hook function.
      Parameters:
      onFlowableAssembly - the hook function to set, null allowed
    • setOnMaybeAssembly

      public static void setOnMaybeAssembly(@Nullable @Nullable Function<? super Maybe, ? extends Maybe> onMaybeAssembly)
      Sets the specific hook function.
      Parameters:
      onMaybeAssembly - the hook function to set, null allowed
    • setOnConnectableFlowableAssembly

      public static void setOnConnectableFlowableAssembly(@Nullable @Nullable Function<? super ConnectableFlowable, ? extends ConnectableFlowable> onConnectableFlowableAssembly)
      Sets the specific hook function.
      Parameters:
      onConnectableFlowableAssembly - the hook function to set, null allowed
    • setOnFlowableSubscribe

      public static void setOnFlowableSubscribe(@Nullable @Nullable BiFunction<? super Flowable, @NonNull ? super Flow.Subscriber, @NonNull ? extends Flow.Subscriber> onFlowableSubscribe)
      Sets the specific hook function.
      Parameters:
      onFlowableSubscribe - the hook function to set, null allowed
    • setOnMaybeSubscribe

      public static void setOnMaybeSubscribe(@Nullable @Nullable BiFunction<? super Maybe, @NonNull MaybeObserver, @NonNull ? extends MaybeObserver> onMaybeSubscribe)
      Sets the specific hook function.
      Parameters:
      onMaybeSubscribe - the hook function to set, null allowed
    • setOnObservableAssembly

      public static void setOnObservableAssembly(@Nullable @Nullable Function<? super Observable, ? extends Observable> onObservableAssembly)
      Sets the specific hook function.
      Parameters:
      onObservableAssembly - the hook function to set, null allowed
    • setOnConnectableObservableAssembly

      public static void setOnConnectableObservableAssembly(@Nullable @Nullable Function<? super ConnectableObservable, ? extends ConnectableObservable> onConnectableObservableAssembly)
      Sets the specific hook function.
      Parameters:
      onConnectableObservableAssembly - the hook function to set, null allowed
    • setOnObservableSubscribe

      public static void setOnObservableSubscribe(@Nullable @Nullable BiFunction<? super Observable, @NonNull ? super Observer, @NonNull ? extends Observer> onObservableSubscribe)
      Sets the specific hook function.
      Parameters:
      onObservableSubscribe - the hook function to set, null allowed
    • setOnSingleAssembly

      public static void setOnSingleAssembly(@Nullable @Nullable Function<? super Single, ? extends Single> onSingleAssembly)
      Sets the specific hook function.
      Parameters:
      onSingleAssembly - the hook function to set, null allowed
    • setOnSingleSubscribe

      public static void setOnSingleSubscribe(@Nullable @Nullable BiFunction<? super Single, @NonNull ? super SingleObserver, @NonNull ? extends SingleObserver> onSingleSubscribe)
      Sets the specific hook function.
      Parameters:
      onSingleSubscribe - the hook function to set, null allowed
    • onSubscribe

      @NonNull public static <@NonNull T> @NonNull Flow.Subscriber<? super T> onSubscribe(@NonNull @NonNull Flowable<@NonNull T> source, @NonNull @NonNull Flow.Subscriber<? super @NonNull T> subscriber)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      subscriber - the subscriber
      Returns:
      the value returned by the hook
    • onSubscribe

      @NonNull public static <@NonNull T> @NonNull Observer<? super T> onSubscribe(@NonNull @NonNull Observable<@NonNull T> source, @NonNull @NonNull Observer<? super @NonNull T> observer)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      observer - the observer
      Returns:
      the value returned by the hook
    • onSubscribe

      @NonNull public static <@NonNull T> @NonNull SingleObserver<? super T> onSubscribe(@NonNull @NonNull Single<@NonNull T> source, @NonNull @NonNull SingleObserver<? super @NonNull T> observer)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      observer - the observer
      Returns:
      the value returned by the hook
    • onSubscribe

      Calls the associated hook function.
      Parameters:
      source - the hook's input value
      observer - the observer
      Returns:
      the value returned by the hook
    • onSubscribe

      @NonNull public static <@NonNull T> @NonNull MaybeObserver<? super T> onSubscribe(@NonNull @NonNull Maybe<@NonNull T> source, @NonNull @NonNull MaybeObserver<? super @NonNull T> observer)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      observer - the subscriber
      Returns:
      the value returned by the hook
    • onSubscribe

      @NonNull public static <@NonNull T> @NonNull Flow.Subscriber<? super T>[] onSubscribe(@NonNull @NonNull ParallelFlowable<? extends @NonNull T> source, @NonNull @NonNull Flow.Subscriber<? super @NonNull T>[] subscribers)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      subscribers - the array of subscribers
      Returns:
      the value returned by the hook
    • onAssembly

      @NonNull public static <@NonNull T> @NonNull Maybe<T> onAssembly(@NonNull @NonNull Maybe<@NonNull T> source)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • onAssembly

      @NonNull public static <@NonNull T> @NonNull Flowable<T> onAssembly(@NonNull @NonNull Flowable<@NonNull T> source)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • onAssembly

      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • onAssembly

      @NonNull public static <@NonNull T> @NonNull Observable<T> onAssembly(@NonNull @NonNull Observable<@NonNull T> source)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • onAssembly

      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • onAssembly

      @NonNull public static <@NonNull T> @NonNull Single<T> onAssembly(@NonNull @NonNull Single<@NonNull T> source)
      Calls the associated hook function.
      Type Parameters:
      T - the value type
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • onAssembly

      @NonNull public static @NonNull Completable onAssembly(@NonNull @NonNull Completable source)
      Calls the associated hook function.
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
    • setOnParallelAssembly

      public static void setOnParallelAssembly(@Nullable @Nullable Function<? super ParallelFlowable, ? extends ParallelFlowable> handler)
      Sets the specific hook function.

      History: 2.0.6 - experimental; 2.1 - beta

      Parameters:
      handler - the hook function to set, null allowed
      Since:
      2.2
    • getOnParallelAssembly

      @Nullable public static @Nullable Function<? super ParallelFlowable, ? extends ParallelFlowable> getOnParallelAssembly()
      Returns the current hook function.

      History: 2.0.6 - experimental; 2.1 - beta

      Returns:
      the hook function, may be null
      Since:
      2.2
    • setOnParallelSubscribe

      public static void setOnParallelSubscribe(@Nullable @Nullable BiFunction<? super ParallelFlowable, @NonNull ? super Flow.Subscriber<@NonNull ?>[], @NonNull ? extends Flow.Subscriber<@NonNull ?>[]> handler)
      Sets the specific hook function.

      History: 3.0.11 - experimental

      Parameters:
      handler - the hook function to set, null allowed
      Since:
      3.1.0
    • getOnParallelSubscribe

      @Nullable public static @Nullable BiFunction<? super ParallelFlowable, @NonNull ? super Flow.Subscriber<@NonNull ?>[], @NonNull ? extends Flow.Subscriber<@NonNull ?>[]> getOnParallelSubscribe()
      Returns the current hook function.

      History: 3.0.11 - experimental

      Returns:
      the hook function, may be null
      Since:
      3.1.0
    • onAssembly

      Calls the associated hook function.

      History: 2.0.6 - experimental; 2.1 - beta

      Type Parameters:
      T - the value type of the source
      Parameters:
      source - the hook's input value
      Returns:
      the value returned by the hook
      Since:
      2.2
    • onBeforeBlocking

      public static boolean onBeforeBlocking()
      Called before an operator attempts a blocking operation such as awaiting a condition or signal and should return true to indicate the operator should not block but throw an IllegalArgumentException.

      History: 2.0.5 - experimental

      Returns:
      true if the blocking should be prevented
      Since:
      2.1
      See Also:
    • setOnBeforeBlocking

      public static void setOnBeforeBlocking(@Nullable @Nullable BooleanSupplier handler)
      Set the handler that is called when an operator attempts a blocking await; the handler should return true to prevent the blocking and to signal an IllegalStateException instead.

      History: 2.0.5 - experimental

      Parameters:
      handler - the handler to set, null resets to the default handler that always returns false
      Since:
      2.1
      See Also:
    • getOnBeforeBlocking

      @Nullable public static @Nullable BooleanSupplier getOnBeforeBlocking()
      Returns the current blocking handler or null if no custom handler is set.

      History: 2.0.5 - experimental

      Returns:
      the current blocking handler or null if not specified
      Since:
      2.1
    • createComputationScheduler

      @NonNull public static @NonNull Scheduler createComputationScheduler(@NonNull @NonNull ThreadFactory threadFactory)
      Create an instance of the default Scheduler used for Schedulers.computation() except using threadFactory for thread creation.

      History: 2.0.5 - experimental

      Parameters:
      threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
      Returns:
      the created Scheduler instance
      Since:
      2.1
    • createCachedScheduler

      @NonNull public static @NonNull Scheduler createCachedScheduler(@NonNull @NonNull ThreadFactory threadFactory)
      Create an instance of the default Scheduler used for Schedulers.cached() except using threadFactory for thread creation.

      History: 2.0.5 - experimental

      Parameters:
      threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
      Returns:
      the created Scheduler instance
      Since:
      4.0.0
    • createNewThreadScheduler

      @NonNull public static @NonNull Scheduler createNewThreadScheduler(@NonNull @NonNull ThreadFactory threadFactory)
      Create an instance of the default Scheduler used for Schedulers.newThread() except using threadFactory for thread creation.

      History: 2.0.5 - experimental

      Parameters:
      threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
      Returns:
      the created Scheduler instance
      Since:
      2.1
    • createSingleScheduler

      @NonNull public static @NonNull Scheduler createSingleScheduler(@NonNull @NonNull ThreadFactory threadFactory)
      Create an instance of the default Scheduler used for Schedulers.single() except using threadFactory for thread creation.

      History: 2.0.5 - experimental

      Parameters:
      threadFactory - thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
      Returns:
      the created Scheduler instance
      Since:
      2.1
    • createExecutorScheduler

      @NonNull public static @NonNull Scheduler createExecutorScheduler(@NonNull @NonNull Executor executor, boolean interruptibleWorker, boolean fair)
      Create an instance of a Scheduler by wrapping an existing Executor.

      This method allows creating an Executor-backed Scheduler before the Schedulers class would initialize the standard Schedulers.

      Parameters:
      executor - the Executor to wrap and turn into a Scheduler.
      interruptibleWorker - if true, the tasks submitted to the Scheduler.Worker will be interrupted when the task is disposed.
      fair - if true, tasks submitted to the Scheduler or Worker will be executed by the underlying Executor one after the other, still in a FIFO and non-overlapping manner, but allows interleaving with other tasks submitted to the underlying Executor. If false, the underlying FIFO scheme will execute as many tasks as it can before giving up the underlying Executor thread.
      Returns:
      the new Scheduler wrapping the Executor
      Since:
      3.1.0
    • createDeferredExecutorScheduler

      @NonNull public static @NonNull Scheduler createDeferredExecutorScheduler(@NonNull @NonNull Supplier<? extends Executor> executorSupplier, boolean interruptibleWorker, boolean fair)
      Create an instance of a Scheduler by wrapping a supplier of a Executor.

      This method allows creating a deferred Executor-backed Scheduler before the Schedulers class would initialize the standard Schedulers.

      Parameters:
      executorSupplier - the Executor supplier to wrap and turn into a Scheduler.
      interruptibleWorker - if true, the tasks submitted to the Scheduler.Worker will be interrupted when the task is disposed.
      fair - if true, tasks submitted to the Scheduler or Worker will be executed by the underlying Executor one after the other, still in a FIFO and non-overlapping manner, but allows interleaving with other tasks submitted to the underlying Executor. If false, the underlying FIFO scheme will execute as many tasks as it can before giving up the underlying Executor thread.
      Returns:
      the new Scheduler wrapping the Executor
      Since:
      4.0.0