Package rx
Class Scheduler.Worker
- java.lang.Object
-
- rx.Scheduler.Worker
-
- All Implemented Interfaces:
Subscription
- Direct Known Subclasses:
CachedThreadScheduler.EventLoopWorker
,EventLoopsScheduler.EventLoopWorker
,ExecutorScheduler.ExecutorSchedulerWorker
,ImmediateScheduler.InnerImmediateScheduler
,NewThreadWorker
,TestScheduler.InnerTestScheduler
,TrampolineScheduler.InnerCurrentThreadScheduler
- Enclosing class:
- Scheduler
public abstract static class Scheduler.Worker extends java.lang.Object implements Subscription
Sequential Scheduler for executing actions on a single thread or event loop.Unsubscribing the
Scheduler.Worker
unschedules all outstanding work and allows resources cleanup.
-
-
Constructor Summary
Constructors Constructor Description Worker()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description long
now()
Gets the current time, in milliseconds, according to this Scheduler.abstract Subscription
schedule(Action0 action)
Schedules an Action for execution.abstract Subscription
schedule(Action0 action, long delayTime, java.util.concurrent.TimeUnit unit)
Schedules an Action for execution at some point in the future.Subscription
schedulePeriodically(Action0 action, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
Schedules a cancelable action to be executed periodically.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface rx.Subscription
isUnsubscribed, unsubscribe
-
-
-
-
Method Detail
-
schedule
public abstract Subscription schedule(Action0 action)
Schedules an Action for execution.- Parameters:
action
- Action to schedule- Returns:
- a subscription to be able to unsubscribe the action (unschedule it if not executed)
-
schedule
public abstract Subscription schedule(Action0 action, long delayTime, java.util.concurrent.TimeUnit unit)
Schedules an Action for execution at some point in the future.Note to implementors: non-positive
delayTime
should be regarded as undelayed schedule, i.e., as if theschedule(rx.functions.Action0)
was called.- Parameters:
action
- the Action to scheduledelayTime
- time to wait before executing the action; non-positive values indicate an undelayed scheduleunit
- the time unit ofdelayTime
- Returns:
- a subscription to be able to unsubscribe the action (unschedule it if not executed)
-
schedulePeriodically
public Subscription schedulePeriodically(Action0 action, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
Schedules a cancelable action to be executed periodically. This default implementation schedules recursively and waits for actions to complete (instead of potentially executing long-running actions concurrently). Each scheduler that can do periodic scheduling in a better way should override this.Note to implementors: non-positive
initialTime
andperiod
should be regarded as undelayed scheduling of the first and any subsequent executions.- Parameters:
action
- the Action to execute periodicallyinitialDelay
- time to wait before executing the action for the first time; non-positive values indicate an undelayed scheduleperiod
- the time interval to wait each time in between executing the action; non-positive values indicate no delay between repeated schedulesunit
- the time unit ofperiod
- Returns:
- a subscription to be able to unsubscribe the action (unschedule it if not executed)
-
now
public long now()
Gets the current time, in milliseconds, according to this Scheduler.- Returns:
- the scheduler's notion of current absolute time in milliseconds
-
-