|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.smartwerkz.jupload.classic.util.concurrent.Executor
public class Executor
Used for executing background tasks. You can add tasks to a queue that the Executor
will work through. Also a finalTask can be set that will be executed whenever
the Executor finished performing a task and the queue is empty.
While executing the final task, the Executor is still busy.
Some critical operations are synchronized against each other
to avoid any ambigious results when calling eg start and stop at the same time
from different threads.
| Field Summary | |
|---|---|
protected Task |
currentTask
|
protected ObservedThread |
thread
|
| Constructor Summary | |
|---|---|
Executor(java.lang.String id,
java.lang.String name)
Creates a new Executor that uses the given name. |
|
| Method Summary | |
|---|---|
boolean |
busy()
Indicates that the Executor is currently performing a task. |
boolean |
cancelled()
Indicates wether this Executor's tasks have just been cancelled. |
boolean |
cancelTasks()
Cancels all current tasks and the loading thread will idle as soon as it finished its current task (if it has any). |
Task |
getCurrentTask()
|
static java.util.List |
getExecutors(java.lang.String id)
|
java.lang.String |
getName()
Returns the name of the Executor's thread. |
java.lang.Thread |
getThread()
|
Validator |
getValidator()
Will stop accepting when the current or next set of tasks has been cancelled. |
boolean |
hasTasks()
Indicates that there are tasks enqueued that are waiting to be executed. |
boolean |
isRunning()
Returns true if the executor has been started with start() |
void |
performLater(Task task)
Enqueues a new task to be performed by the Executor. |
void |
resume()
Will resume this Executor if suspended. |
void |
setFinalTask(java.lang.Runnable task)
Sets the final task which will be executed -if not null- after every time the executor executed all tasks (a task has been executed and the queue is empty) and before it starts waiting for the next. |
void |
start()
Starts execution. |
boolean |
suspend(boolean join)
Suspends the Executor. |
boolean |
suspended()
Indicates wether or not this Executor is suspended. |
void |
terminate(boolean join)
Terminates the Executor (call init to restart it). |
static void |
terminateAll(java.lang.String id)
Terminates all Executors with the given id. |
java.lang.String |
toString()
|
boolean |
waiting()
Indicates wether the Executor is currently idle and not suspended, thus ready to instantly perform any new task. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ObservedThread thread
protected Task currentTask
| Constructor Detail |
|---|
public Executor(java.lang.String id,
java.lang.String name)
id - the id under which this executor will be stored, unique within
one jupload contextname - the name of the executor| Method Detail |
|---|
public void start()
public java.lang.String getName()
public void terminate(boolean join)
join - Indicates that in case, the Executor is currently performing a task,
the calling thread should wait for it to finish.public boolean cancelTasks()
public void performLater(Task task)
public java.lang.Thread getThread()
public Task getCurrentTask()
public boolean hasTasks()
public boolean busy()
public boolean waiting()
public boolean suspended()
public boolean suspend(boolean join)
join - Indicates that in case, the Executor is currently performing a task, the calling thread should wait for it to finish.
public void resume()
public void setFinalTask(java.lang.Runnable task)
public java.lang.String toString()
toString in class java.lang.Objectpublic static java.util.List getExecutors(java.lang.String id)
public static void terminateAll(java.lang.String id)
public boolean isRunning()
start()
public boolean cancelled()
public Validator getValidator()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||