public final class RxJavaCommonPlugins
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static Scheduler |
createComputationScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.computation()
except using threadFactory for thread creation. |
static Scheduler |
createIoScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.io()
except using threadFactory for thread creation. |
static Scheduler |
createNewThreadScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.newThread()
except using threadFactory for thread creation. |
static Scheduler |
createSingleScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the default
Scheduler used for Schedulers.single()
except using threadFactory for thread creation. |
static Function<? super Scheduler,? extends Scheduler> |
getComputationSchedulerHandler()
Returns the current hook function.
|
static Consumer<? super java.lang.Throwable> |
getErrorHandler()
Returns the a hook consumer.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitComputationSchedulerHandler()
Returns the current hook function.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitIoSchedulerHandler()
Returns the current hook function.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitNewThreadSchedulerHandler()
Returns the current hook function.
|
static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> |
getInitSingleSchedulerHandler()
Returns the current hook function.
|
static Function<? super Scheduler,? extends Scheduler> |
getIoSchedulerHandler()
Returns the current hook function.
|
static Function<? super Scheduler,? extends Scheduler> |
getNewThreadSchedulerHandler()
Returns the current hook function.
|
static BooleanSupplier |
getOnBeforeBlocking()
Returns the current blocking handler or null if no custom handler
is set.
|
static Function<? super java.lang.Runnable,? extends java.lang.Runnable> |
getScheduleHandler()
Returns the current hook function.
|
static Function<? super Scheduler,? extends Scheduler> |
getSingleSchedulerHandler()
Returns the current hook function.
|
static Scheduler |
initComputationScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
initIoScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
initNewThreadScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
initSingleScheduler(java.util.concurrent.Callable<Scheduler> defaultScheduler)
Calls the associated hook function.
|
static boolean |
isFailOnNonBlockingScheduler()
Returns true if the blockingX operators fail
with an IllegalStateException on a non-blocking scheduler
such as computation or single.
|
static boolean |
isLockdown()
Returns true if the plugins were locked down.
|
static void |
lockdown()
Prevents changing the plugins from then on.
|
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.
|
static Scheduler |
onComputationScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static void |
onError(java.lang.Throwable error)
Called when an undeliverable error occurs.
|
static Scheduler |
onIoScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static Scheduler |
onNewThreadScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static java.lang.Runnable |
onSchedule(java.lang.Runnable run)
Called when a task is scheduled.
|
static Scheduler |
onSingleScheduler(Scheduler defaultScheduler)
Calls the associated hook function.
|
static void |
reset()
Removes all handlers and resets to default behavior.
|
static void |
setComputationSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setErrorHandler(Consumer<? super java.lang.Throwable> handler)
Sets the specific hook function.
|
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.
|
static void |
setInitComputationSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setInitIoSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setInitNewThreadSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setInitSingleSchedulerHandler(Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setIoSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setNewThreadSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
static void |
setOnBeforeBlocking(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.
|
static void |
setScheduleHandler(Function<? super java.lang.Runnable,? extends java.lang.Runnable> handler)
Sets the specific hook function.
|
static void |
setSingleSchedulerHandler(Function<? super Scheduler,? extends Scheduler> handler)
Sets the specific hook function.
|
public static void lockdown()
This allows container-like environments to prevent clients messing with plugins.
public static boolean isLockdown()
public static void setFailOnNonBlockingScheduler(boolean enable)
History: 2.0.5 - experimental
enable - enable or disable the featurepublic static boolean isFailOnNonBlockingScheduler()
History: 2.0.5 - experimental
@Nullable public static Function<? super Scheduler,? extends Scheduler> getComputationSchedulerHandler()
@Nullable public static Consumer<? super java.lang.Throwable> getErrorHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitComputationSchedulerHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitIoSchedulerHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitNewThreadSchedulerHandler()
@Nullable public static Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> getInitSingleSchedulerHandler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getIoSchedulerHandler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getNewThreadSchedulerHandler()
@Nullable public static Function<? super java.lang.Runnable,? extends java.lang.Runnable> getScheduleHandler()
@Nullable public static Function<? super Scheduler,? extends Scheduler> getSingleSchedulerHandler()
@NonNull public static Scheduler initComputationScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler - a Callable which returns the hook's input valuejava.lang.NullPointerException - if the callable parameter or its result are null@NonNull public static Scheduler initIoScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler - a Callable which returns the hook's input valuejava.lang.NullPointerException - if the callable parameter or its result are null@NonNull public static Scheduler initNewThreadScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler - a Callable which returns the hook's input valuejava.lang.NullPointerException - if the callable parameter or its result are null@NonNull public static Scheduler initSingleScheduler(@NonNull java.util.concurrent.Callable<Scheduler> defaultScheduler)
defaultScheduler - a Callable which returns the hook's input valuejava.lang.NullPointerException - if the callable parameter or its result are null@NonNull public static Scheduler onComputationScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler - the hook's input valuepublic static void onError(@NonNull java.lang.Throwable error)
error - the error to report@NonNull public static Scheduler onIoScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler - the hook's input value@NonNull public static Scheduler onNewThreadScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler - the hook's input value@NonNull public static java.lang.Runnable onSchedule(@NonNull java.lang.Runnable run)
run - the runnable instance@NonNull public static Scheduler onSingleScheduler(@NonNull Scheduler defaultScheduler)
defaultScheduler - the hook's input valuepublic static void reset()
public static void setComputationSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler - the hook function to set, null allowedpublic static void setErrorHandler(@Nullable Consumer<? super java.lang.Throwable> handler)
handler - the hook function to set, null allowedpublic static void setInitComputationSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler - the hook function to set, null allowed, but the function may not return nullpublic static void setInitIoSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler - the hook function to set, null allowed, but the function may not return nullpublic static void setInitNewThreadSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler - the hook function to set, null allowed, but the function may not return nullpublic static void setInitSingleSchedulerHandler(@Nullable Function<? super java.util.concurrent.Callable<Scheduler>,? extends Scheduler> handler)
handler - the hook function to set, null allowed, but the function may not return nullpublic static void setIoSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler - the hook function to set, null allowedpublic static void setNewThreadSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler - the hook function to set, null allowedpublic static void setScheduleHandler(@Nullable Function<? super java.lang.Runnable,? extends java.lang.Runnable> handler)
handler - the hook function to set, null allowedpublic static void setSingleSchedulerHandler(@Nullable Function<? super Scheduler,? extends Scheduler> handler)
handler - the hook function to set, null allowedpublic static boolean onBeforeBlocking()
History: 2.0. - experimental
setFailOnNonBlockingScheduler(boolean)public static void setOnBeforeBlocking(@Nullable BooleanSupplier handler)
History: 2.0.5 - experimental
handler - the handler to set, null resets to the default handler
that always returns falseonBeforeBlocking()@Nullable public static BooleanSupplier getOnBeforeBlocking()
History: 2.0.5 - experimental
@NonNull public static Scheduler createComputationScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler used for Schedulers.computation()
except using threadFactory for thread creation.
History: 2.0.5 - experimental
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.@NonNull public static Scheduler createIoScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler used for Schedulers.io()
except using threadFactory for thread creation.
History: 2.0.5 - experimental
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.@NonNull public static Scheduler createNewThreadScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler used for Schedulers.newThread()
except using threadFactory for thread creation.
History: 2.0.5 - experimental
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.@NonNull public static Scheduler createSingleScheduler(@NonNull java.util.concurrent.ThreadFactory threadFactory)
Scheduler used for Schedulers.single()
except using threadFactory for thread creation.
History: 2.0.5 - experimental
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.