| Modifier and Type | Class | Description |
|---|---|---|
class |
TaskDaemon.PeriodicTask |
A PeriodicTask is a task that automatically reschedules itself so that
it executes on a periodic basis.
|
Daemon.DaemonWorkerBase.LoggingWriter, Base.StackFrame| Constructor | Description |
|---|---|
TaskDaemon() |
Default constructor.
|
TaskDaemon(String sName) |
Creates a TaskDaemon with the specified name.
|
TaskDaemon(String sName,
int nPriority,
boolean fStart) |
Creates a TaskDaemon with a specified name and priority.
|
TaskDaemon(String sName,
int nPriority,
boolean fStart,
boolean fFinish,
int cMillisTimeout) |
Creates a TaskDaemon with a specified name and priority.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
executePeriodicTask(Runnable task,
long cMillisInterval) |
Schedule a periodic task to be run "as soon as possible", and to repeat
at the specified interval.
|
void |
executeTask(Runnable task) |
Schedule a task to be run by the daemon "as soon as possible".
|
protected String |
getDescription() |
Format the Daemon attributes into a String for inclusion in the String
returned from the
Daemon.toString() method. |
long |
getIdleTimeout() |
Determine the length of time that the daemon will live without any
activity before it stops itself.
|
protected long |
getMostRecentTaskTime() |
Determine when the most recent task was run.
|
protected LongArray |
getTasks() |
Obtain the pending tasks.
|
protected Runnable |
instantiatePeriodicTask(Runnable task,
long cMillisInterval) |
Create a task that will automatically be run on a periodic basis.
|
boolean |
isFinishing() |
Determine if the daemon will finish those scheduled tasks that are
ripe (presently due to be run) before stopping.
|
protected void |
onException(Throwable e,
Runnable task) |
Process an exception that is thrown during a task execution.
|
void |
run() |
The task processing loop.
|
protected void |
run(Runnable task) |
Execute a Runnable task.
|
void |
schedulePeriodicTask(Runnable task,
long ldtFirst,
long cMillisInterval) |
Schedule a periodic task to be run at the specified time, and to
repeat at the specified interval.
|
void |
scheduleTask(Runnable task,
long ldt) |
Schedule a task to be run at the specified time, or as soon after
as possible.
|
void |
setFinishing(boolean fFinish) |
Specify whether the daemon will finish scheduled tasks before stopping.
|
void |
setIdleTimeout(long cMillis) |
Configure the daemon's timeout.
|
void |
stop(boolean fFinish) |
Request the daemon to stop, optionally completing tasks that have
already been scheduled and are ready to be run.
|
protected Runnable |
takeNextRipeTask() |
Wait for the next scheduled task is ripe (due or overdue), then
remove it from the pending schedule and return it.
|
String |
toString() |
Return a human-readable String representation of the Daemon.
|
protected void |
updateMostRecentTaskTime() |
Set the time that the most recent task was run to the current time.
|
changeState, configureWorker, ensureThreadGroup, finishStarting, finishStopping, getConfiguredName, getConfiguredPriority, getContext, getGuardRegisterAction, getMaxWaitMillis, getState, getThread, getThreadContextClassLoader, getWorker, guardIfNeeded, heartbeat, heartbeat, instantiateWorker, isGuarded, isOnWorkerThread, isRunning, isStopping, recover, setConfiguredName, setConfiguredPriority, setContext, setGuardPolicy, setGuardRegisterAction, setThreadContextClassLoader, shutdown, start, stop, terminate, toStateStringazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, waitpublic TaskDaemon()
public TaskDaemon(String sName)
sName - the thread name (may be null)public TaskDaemon(String sName, int nPriority, boolean fStart)
sName - the thread name (may be null)nPriority - the thread priority, between Thread.MIN_PRIORITY and
Thread.MAX_PRIORITY inclusivefStart - pass true to start the thread immediatelypublic TaskDaemon(String sName, int nPriority, boolean fStart, boolean fFinish, int cMillisTimeout)
sName - the thread name (may be null)nPriority - the thread priority, between Thread.MIN_PRIORITY and
Thread.MAX_PRIORITY inclusivefStart - pass true to start the thread immediatelyfFinish - pass true to makes sure ripe tasks are run before the
daemon shuts downcMillisTimeout - the number of milliseconds to wait after the
previous task finished for a new task to be
submitted before automatically shutting down the
daemon threadpublic void run()
public void stop(boolean fFinish)
fFinish - pass true if the daemon should finish any tasks that
have already been scheduled before stoppingpublic boolean isFinishing()
public void setFinishing(boolean fFinish)
fFinish - pass true to force the daemon to finish any scheduled
tasks before stoppingpublic long getIdleTimeout()
public void setIdleTimeout(long cMillis)
cMillis - if greater than zero, the number of milliseconds that
the daemon will wait with nothing in the queue before
shutting itself downpublic void executeTask(Runnable task)
task - a Runnable object to invokepublic void scheduleTask(Runnable task, long ldt)
task - a Runnable object to invokeldt - a datetime value at which to run the taskpublic void executePeriodicTask(Runnable task, long cMillisInterval)
task - a Runnable object to invokecMillisInterval - the number of milliseconds to wait after the
task is run before running it againpublic void schedulePeriodicTask(Runnable task, long ldtFirst, long cMillisInterval)
task - a Runnable object to invokeldtFirst - a datetime value at which to first run the taskcMillisInterval - the number of milliseconds to wait after the
task is run before running it againprotected LongArray getTasks()
protected Runnable takeNextRipeTask() throws InterruptedException
InterruptedException - if this thread is interrupted while waiting
for the next taskprotected void run(Runnable task)
task - a Runnable objectprotected long getMostRecentTaskTime()
protected void updateMostRecentTaskTime()
protected Runnable instantiatePeriodicTask(Runnable task, long cMillisInterval)
task - the actual task to runcMillisInterval - the period of time, in milliseconds, to
wait between runs of the taskpublic String toString()
protected String getDescription()
Daemon.toString() method.getDescription in class Daemon