public abstract class DaemonThread extends java.lang.Object implements DaemonRunner, java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
name |
protected int |
nWakeupRequests |
protected boolean |
stifleExceptionChatter |
protected java.util.Set |
workQueue |
protected Latch |
workQueueLatch |
| Constructor and Description |
|---|
DaemonThread(long waitTime,
java.lang.String name,
EnvironmentImpl env) |
| Modifier and Type | Method and Description |
|---|---|
void |
addToQueue(java.lang.Object o) |
void |
addToQueueAlreadyLatched(java.util.Collection c) |
int |
getNWakeupRequests()
For unit testing.
|
int |
getQueueSize() |
java.lang.Thread |
getThread()
For testing.
|
protected boolean |
isPaused()
Returns whether the daemon is currently paused/disabled.
|
boolean |
isRunning()
Returns whether the onWakeup method is currently executing.
|
protected boolean |
isShutdownRequested()
Returns whether shutdown has been requested.
|
protected int |
nDeadlockRetries()
Returns the number of retries to perform when Deadlock Exceptions
occur.
|
protected abstract void |
onWakeup()
onWakeup is synchronized to ensure that multiple invocations of the
DaemonThread aren't made.
|
void |
requestShutdown() |
void |
run() |
void |
runOrPause(boolean run)
If run is true, starts the thread if not started or unpauses it
if already started; if run is false, pauses the thread if
started or does nothing if not started.
|
void |
shutdown()
Requests shutdown and calls join() to wait for the thread to stop.
|
java.lang.String |
toString() |
void |
wakeup() |
protected java.lang.String name
protected java.util.Set workQueue
protected Latch workQueueLatch
protected int nWakeupRequests
protected boolean stifleExceptionChatter
public DaemonThread(long waitTime,
java.lang.String name,
EnvironmentImpl env)
public java.lang.Thread getThread()
public void runOrPause(boolean run)
runOrPause in interface DaemonRunnerpublic void requestShutdown()
requestShutdown in interface DaemonRunnerpublic void shutdown()
shutdown in interface DaemonRunnerpublic java.lang.String toString()
toString in class java.lang.Objectpublic void addToQueue(java.lang.Object o)
throws DatabaseException
DatabaseExceptionpublic int getQueueSize()
throws DatabaseException
DatabaseExceptionpublic void addToQueueAlreadyLatched(java.util.Collection c)
throws DatabaseException
DatabaseExceptionpublic void wakeup()
public void run()
run in interface java.lang.Runnableprotected int nDeadlockRetries()
throws DatabaseException
DatabaseExceptionprotected abstract void onWakeup()
throws DatabaseException
DatabaseExceptionprotected boolean isShutdownRequested()
protected boolean isPaused()
public boolean isRunning()
public int getNWakeupRequests()
getNWakeupRequests in interface DaemonRunner