|
ozone core API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ozoneDB.core.storage.gammaStore.AsyncExec
Runs tasks in a separate thread. Tasks are identified by the keys used to put them in this AsyncExec. When a task has been run, it will be automatically removed from this instance.
If a task throws a Throwable
in its run()
method,
it will be caught and displayed; the thread handling all tasks will continue
normally.
For every instance of this class 1 thread is created, so keep this in mind when creating instances...
Nested Class Summary | |
private class |
AsyncExec.ProcessorThread
Handles all execution of tasks. |
Field Summary | |
private java.util.LinkedHashMap |
_map
|
private java.lang.Object |
currentKey
key of the Runnable that is currently being processed, or
has recently finished its run() method. |
private static java.util.logging.Logger |
log
|
private static int |
NOT_STARTED
|
private static int |
RUNNING
|
private int |
status
|
private static int |
STOPPED
|
private static int |
STOPPING
|
private AsyncExec.ProcessorThread |
thread
|
Constructor Summary | |
AsyncExec(java.lang.String threadName,
int priority,
boolean useDaemonThread)
|
Method Summary | |
private void |
checkStatus()
|
java.lang.Runnable |
get(java.lang.Object key)
Returns the task that was put into this instance with the specified key. |
private java.lang.Object |
getCurrentKey()
|
private java.util.Map |
getMap()
|
private int |
getStatus()
|
java.lang.Runnable |
put(java.lang.Object key,
java.lang.Runnable task)
Puts a task into this instance. |
java.lang.Runnable |
remove(java.lang.Object key)
Removes the task that was put into this instance with the specified key. |
private void |
setCurrentKey(java.lang.Object currentKey)
|
private void |
setStatus(int status)
|
int |
size()
Returns the number of tasks currently in this instance. |
void |
stopWhenReady()
Tells this instance to stop; no more tasks can be put in or removed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.util.logging.Logger log
private static final int NOT_STARTED
private static final int RUNNING
private static final int STOPPING
private static final int STOPPED
private java.util.LinkedHashMap _map
private volatile int status
private volatile java.lang.Object currentKey
Runnable
that is currently being processed, or
has recently finished its run()
method.
private AsyncExec.ProcessorThread thread
Constructor Detail |
public AsyncExec(java.lang.String threadName, int priority, boolean useDaemonThread)
Method Detail |
public java.lang.Runnable put(java.lang.Object key, java.lang.Runnable task)
java.util.Map
instances.
key
- key used to identify the given tasktask
- task to be run
java.lang.IllegalStateException
- if stopped or stoppingprivate void checkStatus()
java.lang.IllegalStateException
- if stopped or stoppingpublic java.lang.Runnable get(java.lang.Object key)
run()
method has completed.
key
- key used to lookup the task
null
if no such key)
java.lang.IllegalStateException
- if stopped or stoppingpublic java.lang.Runnable remove(java.lang.Object key)
key
- key used to lookup the task
null
if no such key)
java.lang.IllegalStateException
- if stopped or stoppingpublic int size()
public void stopWhenReady()
private void setStatus(int status)
private int getStatus()
private java.lang.Object getCurrentKey()
private void setCurrentKey(java.lang.Object currentKey)
private java.util.Map getMap()
|
ozone core API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |