Top Description Fields Constructors Methods
rx.plugins

public Class RxJavaSchedulersHook

extends Object
Class Inheritance
Imports
java.util.concurrent.ThreadFactory, rx.Scheduler, rx.functions.Action0, rx.internal.schedulers.CachedThreadScheduler, .EventLoopsScheduler, .NewThreadScheduler, rx.internal.util.RxThreadFactory, rx.schedulers.Schedulers

This plugin class provides 2 ways to customize Scheduler 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 an Action0, 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

Modifier and TypeField and Description
private static final RxJavaSchedulersHook

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Scheduler

Returns:

the created Scheduler instance
createComputationScheduler
()

Create an instance of the default Scheduler used for Schedulers#computation().

public static Scheduler

Returns:

the created Scheduler instance
createComputationScheduler
(ThreadFactory
the factory to use for each worker thread
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#computation() except using threadFactory for thread creation.

public static Scheduler

Returns:

the created Scheduler instance
createIoScheduler
()

Create an instance of the default Scheduler used for Schedulers#io().

public static Scheduler

Returns:

the created Scheduler instance
createIoScheduler
(ThreadFactory
the factory to use for each worker thread
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#io() except using threadFactory for thread creation.

public static Scheduler

Returns:

the created Scheduler instance
createNewThreadScheduler
()

Create an instance of the default Scheduler used for Schedulers#newThread().

public static Scheduler

Returns:

the created Scheduler instance
createNewThreadScheduler
(ThreadFactory
the factory to use for each worker thread
threadFactory
)

Create an instance of the default Scheduler used for Schedulers#newThread() except using threadFactory for thread creation.

public Scheduler

Returns:

the current computation scheduler instance
getComputationScheduler
()

Scheduler to return from rx.schedulers.Schedulers#computation() or null if default should be used.

public static RxJavaSchedulersHook
public Scheduler

Returns:

the created Scheduler instance
getIOScheduler
()

Scheduler to return from rx.schedulers.Schedulers#io() or null if default should be used.

public Scheduler

Returns:

the current new thread scheduler instance
getNewThreadScheduler
()

Scheduler to return from rx.schedulers.Schedulers#newThread() or null if default should be used.

public Action0

Returns:

wrapped action to schedule
onSchedule
(Action0
action to schedule
action
)

Deprecated
Invoked before the Action is handed over to the scheduler.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_INSTANCEback to summary
private static final RxJavaSchedulersHook DEFAULT_INSTANCE

Constructor Detail

RxJavaSchedulersHookback to summary
public RxJavaSchedulersHook()

Method Detail

createComputationSchedulerback to summary
public static Scheduler createComputationScheduler()

Create an instance of the default Scheduler used for Schedulers#computation().

Returns:Scheduler

the created Scheduler instance

Since
1.3
createComputationSchedulerback to summary
public static Scheduler createComputationScheduler(ThreadFactory threadFactory)

Create an instance of the default Scheduler used for Schedulers#computation() except using threadFactory for thread creation.

Parameters
threadFactory:ThreadFactory

the factory to use for each worker thread

Returns:Scheduler

the created Scheduler instance

Since
1.3
createIoSchedulerback to summary
public static Scheduler createIoScheduler()

Create an instance of the default Scheduler used for Schedulers#io().

Returns:Scheduler

the created Scheduler instance

Since
1.3
createIoSchedulerback to summary
public static Scheduler createIoScheduler(ThreadFactory threadFactory)

Create an instance of the default Scheduler used for Schedulers#io() except using threadFactory for thread creation.

Parameters
threadFactory:ThreadFactory

the factory to use for each worker thread

Returns:Scheduler

the created Scheduler instance

Since
1.3
createNewThreadSchedulerback to summary
public static Scheduler createNewThreadScheduler()

Create an instance of the default Scheduler used for Schedulers#newThread().

Returns:Scheduler

the created Scheduler instance

Since
1.3
createNewThreadSchedulerback to summary
public static Scheduler createNewThreadScheduler(ThreadFactory threadFactory)

Create an instance of the default Scheduler used for Schedulers#newThread() except using threadFactory for thread creation.

Parameters
threadFactory:ThreadFactory

the factory to use for each worker thread

Returns:Scheduler

the created Scheduler instance

Since
1.3
getComputationSchedulerback to summary
public Scheduler getComputationScheduler()

Scheduler to return from rx.schedulers.Schedulers#computation() or null if default should be used. This instance should be or behave like a stateless singleton;

Returns:Scheduler

the current computation scheduler instance

getDefaultInstanceback to summary
public static RxJavaSchedulersHook getDefaultInstance()
getIOSchedulerback to summary
public Scheduler getIOScheduler()

Scheduler to return from rx.schedulers.Schedulers#io() or null if default should be used. This instance should be or behave like a stateless singleton;

Returns:Scheduler

the created Scheduler instance

getNewThreadSchedulerback to summary
public Scheduler getNewThreadScheduler()

Scheduler to return from rx.schedulers.Schedulers#newThread() or null if default should be used. This instance should be or behave like a stateless singleton;

Returns:Scheduler

the current new thread scheduler instance

onScheduleback to summary
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:Action0

action to schedule

Returns:Action0

wrapped action to schedule

Annotations
@Deprecated