public class NewThreadWorker extends Scheduler.Worker implements Subscription
Modifier and Type | Field and Description |
---|---|
static int |
PURGE_FREQUENCY
The purge frequency in milliseconds.
|
Constructor and Description |
---|
NewThreadWorker(ThreadFactory threadFactory) |
Modifier and Type | Method and Description |
---|---|
static void |
deregisterExecutor(ScheduledExecutorService service)
Deregisters the executor service.
|
boolean |
isUnsubscribed()
Indicates whether this
Subscription is currently unsubscribed. |
static void |
registerExecutor(ScheduledThreadPoolExecutor service)
Registers the given executor service and starts the purge thread if not already started.
|
Subscription |
schedule(Action0 action)
Schedules an Action for execution.
|
Subscription |
schedule(Action0 action,
long delayTime,
TimeUnit unit)
Schedules an Action for execution at some point in the future.
|
ScheduledAction |
scheduleActual(Action0 action,
long delayTime,
TimeUnit unit)
Schedules the given action by wrapping it into a ScheduledAction on the
underlying ExecutorService, returning the ScheduledAction.
|
ScheduledAction |
scheduleActual(Action0 action,
long delayTime,
TimeUnit unit,
CompositeSubscription parent) |
ScheduledAction |
scheduleActual(Action0 action,
long delayTime,
TimeUnit unit,
SubscriptionList parent) |
static boolean |
tryEnableCancelPolicy(ScheduledExecutorService executor)
Tries to enable the Java 7+ setRemoveOnCancelPolicy.
|
void |
unsubscribe()
Stops the receipt of notifications on the
Subscriber that was registered when this Subscription
was received. |
now, schedulePeriodically
public static final int PURGE_FREQUENCY
public NewThreadWorker(ThreadFactory threadFactory)
public static void registerExecutor(ScheduledThreadPoolExecutor service)
public
visibility reason: called from other package(s) within RxJava
service
- a scheduled thread pool executor instancepublic static void deregisterExecutor(ScheduledExecutorService service)
public
visibility reason: called from other package(s) within RxJava
service
- a scheduled thread pool executor instancepublic static boolean tryEnableCancelPolicy(ScheduledExecutorService executor)
public
visibility reason: called from other package(s) within RxJava.
If the method returns false, the registerExecutor(ScheduledThreadPoolExecutor)
may
be called to enable the backup option of purging the executors.
executor
- the executor to call setRemoveOnCancelPolicy if available.public Subscription schedule(Action0 action)
Scheduler.Worker
schedule
in class Scheduler.Worker
action
- Action to schedulepublic Subscription schedule(Action0 action, long delayTime, TimeUnit unit)
Scheduler.Worker
Note to implementors: non-positive delayTime
should be regarded as non-delayed schedule, i.e.,
as if the Scheduler.Worker.schedule(rx.functions.Action0)
was called.
schedule
in class Scheduler.Worker
action
- the Action to scheduledelayTime
- time to wait before executing the action; non-positive values indicate an non-delayed
scheduleunit
- the time unit of delayTime
public ScheduledAction scheduleActual(Action0 action, long delayTime, TimeUnit unit)
action
- the action to wrap and scheduledelayTime
- the delay in executionunit
- the time unit of the delaypublic ScheduledAction scheduleActual(Action0 action, long delayTime, TimeUnit unit, CompositeSubscription parent)
public ScheduledAction scheduleActual(Action0 action, long delayTime, TimeUnit unit, SubscriptionList parent)
public void unsubscribe()
Subscription
Subscriber
that was registered when this Subscription
was received.
This allows deregistering an Subscriber
before it has finished receiving all events (i.e. before
onCompleted is called).
unsubscribe
in interface Subscription
public boolean isUnsubscribed()
Subscription
Subscription
is currently unsubscribed.isUnsubscribed
in interface Subscription
true
if this Subscription
is currently unsubscribed, false
otherwiseCopyright © 2018. All rights reserved.