public class TrivialTicker extends java.lang.Object implements Ticker
Constructor and Description |
---|
TrivialTicker(Executor executor) |
Modifier and Type | Method and Description |
---|---|
void |
cancelTimedJob(java.lang.Runnable job) |
Executor |
getExecutor()
Get the underlying Executor.
|
void |
queueTimedJob(java.lang.Runnable job,
long offset)
Run a job after a given delay.
|
void |
queueTimedJob(java.lang.Runnable job,
java.lang.String name,
long offset,
boolean runOnTickerAnyway,
boolean noDupes)
Run a job after a given delay.
|
void |
queueTimedJobAbsolute(java.lang.Runnable runner,
java.lang.String name,
long time,
boolean runOnTickerAnyway,
boolean noDupes)
Run a job at a specified absolute time.
|
void |
removeQueuedJob(java.lang.Runnable job)
Remove a queued job.
|
void |
rescheduleTimedJob(java.lang.Runnable job,
java.lang.String name,
long newOffset)
Changes the offset of a already-queued job.
|
void |
shutdown() |
public TrivialTicker(Executor executor)
public void queueTimedJob(java.lang.Runnable job, long offset)
Ticker
queueTimedJob
in interface Ticker
job
- The Runnable to execute.offset
- The delay in milliseconds.public void queueTimedJob(java.lang.Runnable job, java.lang.String name, long offset, boolean runOnTickerAnyway, boolean noDupes)
Ticker
queueTimedJob
in interface Ticker
job
- The Runnable to execute.name
- The name of the thread to run it.offset
- The delay in milliseconds.runOnTickerAnyway
- If true, start the job from the Ticker thread even if we could pass
it directly through to the Executor. This is needed for increasing thread priorities, since
the Ticker runs at a high priority, and for some tests.noDupes
- If true, ignore the job if it is already queued. Implies runOnTickerAnyway.
WARNING: This does not guarantee that we don't run multiple copies of the job
simultaneously! You must ensure adequate locking. Worse, if the job takes an unexpectedly
long time, you could end up with many copies of the job running simultaneously.public void cancelTimedJob(java.lang.Runnable job)
public void removeQueuedJob(java.lang.Runnable job)
Ticker
removeQueuedJob
in interface Ticker
public void rescheduleTimedJob(java.lang.Runnable job, java.lang.String name, long newOffset)
public void shutdown()
public Executor getExecutor()
Ticker
getExecutor
in interface Ticker
public void queueTimedJobAbsolute(java.lang.Runnable runner, java.lang.String name, long time, boolean runOnTickerAnyway, boolean noDupes)
Ticker
queueTimedJobAbsolute
in interface Ticker
name
- The name of the thread to run it.time
- The time at which to run the job.runOnTickerAnyway
- If true, start the job from the Ticker thread even if we could pass
it directly through to the Executor. This is needed for increasing thread priorities, since
the Ticker runs at a high priority, and for some tests.noDupes
- If true, ignore the job if it is already queued. Implies runOnTickerAnyway.
WARNING: This does not guarantee that we don't run multiple copies of the job
simultaneously! You must ensure adequate locking. Worse, if the job takes an unexpectedly
long time, you could end up with many copies of the job running simultaneously.