Package rx.plugins
Class RxJavaSchedulersHook
- java.lang.Object
-
- rx.plugins.RxJavaSchedulersHook
-
public class RxJavaSchedulersHook extends java.lang.Object
This plugin class provides 2 ways to customizeScheduler
functionality 1. You may redefine entire schedulers, if you so choose. To do so, override the 3 methods that return Scheduler (io(), computation(), newThread()). 2. You may wrap/decorate anAction0
, before it is handed off to a Scheduler. The system- supplied Schedulers (Schedulers.ioScheduler, Schedulers.computationScheduler, Scheduler.newThreadScheduler) all use this hook, so it's a convenient way to modify Scheduler functionality without redefining Schedulers wholesale. Also, when redefining Schedulers, you are free to use/not use the onSchedule decoration hook.See
RxJavaPlugins
or the RxJava GitHub Wiki for information on configuring plugins: https://github.com/ReactiveX/RxJava/wiki/Plugins.
-
-
Field Summary
Fields Modifier and Type Field Description private static RxJavaSchedulersHook
DEFAULT_INSTANCE
-
Constructor Summary
Constructors Constructor Description RxJavaSchedulersHook()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Scheduler
createComputationScheduler()
Create an instance of the defaultScheduler
used forSchedulers.computation()
.static Scheduler
createComputationScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the defaultScheduler
used forSchedulers.computation()
except usingthreadFactory
for thread creation.static Scheduler
createIoScheduler()
Create an instance of the defaultScheduler
used forSchedulers.io()
.static Scheduler
createIoScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the defaultScheduler
used forSchedulers.io()
except usingthreadFactory
for thread creation.static Scheduler
createNewThreadScheduler()
Create an instance of the defaultScheduler
used forSchedulers.newThread()
.static Scheduler
createNewThreadScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the defaultScheduler
used forSchedulers.newThread()
except usingthreadFactory
for thread creation.Scheduler
getComputationScheduler()
Scheduler to return fromSchedulers.computation()
or null if default should be used.static RxJavaSchedulersHook
getDefaultInstance()
Scheduler
getIOScheduler()
Scheduler to return fromSchedulers.io()
or null if default should be used.Scheduler
getNewThreadScheduler()
Scheduler to return fromSchedulers.newThread()
or null if default should be used.Action0
onSchedule(Action0 action)
Deprecated.
-
-
-
Field Detail
-
DEFAULT_INSTANCE
private static final RxJavaSchedulersHook DEFAULT_INSTANCE
-
-
Method Detail
-
createComputationScheduler
@Experimental public static Scheduler createComputationScheduler()
Create an instance of the defaultScheduler
used forSchedulers.computation()
.- Returns:
- the created Scheduler instance
-
createComputationScheduler
@Experimental public static Scheduler createComputationScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the defaultScheduler
used forSchedulers.computation()
except usingthreadFactory
for thread creation.- Parameters:
threadFactory
- the factory to use for each worker thread- Returns:
- the created Scheduler instance
-
createIoScheduler
@Experimental public static Scheduler createIoScheduler()
Create an instance of the defaultScheduler
used forSchedulers.io()
.- Returns:
- the created Scheduler instance
-
createIoScheduler
@Experimental public static Scheduler createIoScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the defaultScheduler
used forSchedulers.io()
except usingthreadFactory
for thread creation.- Parameters:
threadFactory
- the factory to use for each worker thread- Returns:
- the created Scheduler instance
-
createNewThreadScheduler
@Experimental public static Scheduler createNewThreadScheduler()
Create an instance of the defaultScheduler
used forSchedulers.newThread()
.- Returns:
- the created Scheduler instance
-
createNewThreadScheduler
@Experimental public static Scheduler createNewThreadScheduler(java.util.concurrent.ThreadFactory threadFactory)
Create an instance of the defaultScheduler
used forSchedulers.newThread()
except usingthreadFactory
for thread creation.- Parameters:
threadFactory
- the factory to use for each worker thread- Returns:
- the created Scheduler instance
-
getComputationScheduler
public Scheduler getComputationScheduler()
Scheduler to return fromSchedulers.computation()
or null if default should be used. This instance should be or behave like a stateless singleton;- Returns:
- the current computation scheduler instance
-
getIOScheduler
public Scheduler getIOScheduler()
Scheduler to return fromSchedulers.io()
or null if default should be used. This instance should be or behave like a stateless singleton;- Returns:
- the created Scheduler instance
-
getNewThreadScheduler
public Scheduler getNewThreadScheduler()
Scheduler to return fromSchedulers.newThread()
or null if default should be used. This instance should be or behave like a stateless singleton;- Returns:
- the current new thread scheduler instance
-
onSchedule
@Deprecated public Action0 onSchedule(Action0 action)
Deprecated.Invoked before the Action is handed over to the scheduler. Can be used for wrapping/decorating/logging. The default is just a pass through.- Parameters:
action
- action to schedule- Returns:
- wrapped action to schedule
-
getDefaultInstance
public static RxJavaSchedulersHook getDefaultInstance()
-
-