|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
com.cosylab.epics.caj.util.Timer
public class Timer
Timer.
Based on EDU.oswego.cs.dl.util.concurrent (it was not approriate for CAJ usage).
Timer tasks should complete quickly. If a timer task takes excessive time to complete,
it "hogs" the timer's task execution thread. This can, in turn, delay the execution of
subsequent tasks, which may "bunch up" and execute in rapid succession when (and if)
the offending task finally completes.
| Nested Class Summary | |
|---|---|
protected class |
Timer.RunLoop
The runloop is isolated in its own Runnable class just so that the main class need not implement Runnable, which would allow others to directly invoke run, which is not supported. |
static interface |
Timer.TimerRunnable
Timer runnable interface. |
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected Heap |
heap_
Tasks are maintained in a standard priority queue. |
protected Timer.RunLoop |
runLoop_
|
protected Thread |
thread_
The thread used to process commands |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
Timer()
Protected constructor (singleton pattern). |
|
| Method Summary | |
|---|---|
static void |
cancel(Object taskID)
Cancel a scheduled task that has not yet been run. |
protected void |
clearThread()
set thread_ to null to indicate termination |
Object |
executeAfterDelay(long millisecondsToDelay,
Timer.TimerRunnable command)
Excecute the given command after waiting for the given delay. |
Object |
executePeriodically(long period,
Timer.TimerRunnable command,
long firstTime)
Execute the given command every period milliseconds AT FIXED RATE. |
protected com.cosylab.epics.caj.util.Timer.TaskNode |
nextTask()
Return the next task to execute, or null if thread is interrupted. |
void |
restart()
Start (or restart) a thread to process commands, or wake up an existing thread if one is already running. |
void |
shutDown()
Cancel all tasks and interrupt the background thread executing the current task, if any. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Heap heap_
protected Thread thread_
protected final Timer.RunLoop runLoop_
| Constructor Detail |
|---|
public Timer()
| Method Detail |
|---|
public Object executeAfterDelay(long millisecondsToDelay,
Timer.TimerRunnable command)
millisecondsToDelay - -- the number of milliseconds
from now to run the command.command - -- the command to run after the delay.
public Object executePeriodically(long period,
Timer.TimerRunnable command,
long firstTime)
period milliseconds AT FIXED RATE.
If startNow is true, execution begins immediately,
otherwise, it begins after the first period delay.
period - -- the period, in milliseconds. Periods are
measured from start-of-task to the next start-of-task. It is
generally a bad idea to use a period that is shorter than
the expected task duration.command - -- the command to run at each cyclefirstTime - -- time when task should start with execution, 0 means immediately.
IllegalArgumentException - if period less than or equal to zero.public static void cancel(Object taskID)
taskID - -- a task reference returned by one of
the execute commands
ClassCastException - if the taskID argument is not
of the type returned by an execute command.protected void clearThread()
public void restart()
public void shutDown()
protected com.cosylab.epics.caj.util.Timer.TaskNode nextTask()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||