public class Scheduler extends Object
pause()): if paused, then no posted events will be run unless the Scheduler
is explicitly instructed to do so.unPause()): if not paused but not set to idle constantly, then the Scheduler will
automatically run any Runnables that are scheduled to run at or before the
Scheduler's current time, but it won't automatically run any future events. To
run future events the Scheduler needs to have its clock advanced.idleConstantly(boolean) is called with
true, then the Scheduler will continue looping through posted events
(including future events), advancing its clock as it goes.| Constructor and Description |
|---|
Scheduler() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
advanceBy(long interval)
Run all runnables that are scheduled to run in the next time interval.
|
boolean |
advanceTo(long endTime)
Run all runnables that are scheduled before the endTime.
|
boolean |
advanceToLastPostedRunnable()
Run all runnables in the queue.
|
boolean |
advanceToNextPostedRunnable()
Run the next runnable in the queue.
|
boolean |
areAnyRunnable()
Determine if any enqueued runnables are enqueued before the current time.
|
long |
getCurrentTime()
Get the current time (as seen by the scheduler).
|
void |
idleConstantly(boolean shouldIdleConstantly)
Set the idle state of the Scheduler.
|
boolean |
isPaused()
Determine if the scheduler is paused.
|
void |
pause()
Pause the scheduler.
|
void |
post(Runnable runnable)
Add a runnable to the queue.
|
void |
postAtFrontOfQueue(Runnable runnable)
Add a runnable to the head of the queue.
|
void |
postDelayed(Runnable runnable,
long delayMillis)
Add a runnable to the queue to be run after a delay.
|
void |
remove(Runnable runnable)
Remove a runnable from the queue.
|
void |
reset()
Reset the internal state of the Scheduler.
|
boolean |
runOneTask()
Run the next runnable in the queue.
|
int |
size()
Return the number of enqueued runnables.
|
void |
unPause()
Un-pause the scheduler.
|
public long getCurrentTime()
public void pause()
public void unPause()
public boolean isPaused()
public void post(Runnable runnable)
runnable - Runnable to add.public void postDelayed(Runnable runnable, long delayMillis)
runnable - Runnable to add.delayMillis - Delay in millis.public void postAtFrontOfQueue(Runnable runnable)
runnable - Runnable to add.public void remove(Runnable runnable)
runnable - Runnable to remove.public boolean advanceToLastPostedRunnable()
public boolean advanceToNextPostedRunnable()
public boolean advanceBy(long interval)
interval - Time interval (in millis).public boolean advanceTo(long endTime)
endTime - Future time.public boolean runOneTask()
public boolean areAnyRunnable()
public void reset()
public int size()
public void idleConstantly(boolean shouldIdleConstantly)
shouldIdleConstantly - True if the scheduler should idle.Copyright © 2015. All rights reserved.