|
Jacson | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.spieleck.util.TaskQueue
A queue of Tasks (Runnable
s)
for the ThreadPool
.
Field Summary | |
protected java.lang.Object |
cLock
Lock for counting |
protected boolean |
started
Did we allready have an assignement? |
protected java.util.LinkedList |
tasks
The queue of Files which need to be processed |
protected boolean |
workExpected
Can we finish now? |
Constructor Summary | |
TaskQueue()
Construct a queue. |
Method Summary | |
void |
addTask(java.lang.Runnable r)
Add a task to execute |
java.lang.Runnable |
getTask()
Get the next task to execute |
boolean |
isStarted()
Have we been started ? |
boolean |
isWorkLeft()
Is there something left to do? |
void |
setWorkExpected(boolean workExpected)
In case we expect that the queue empties in between (since we are feeding in tasks slowly and the tasks finish fast), but we want to avoid isWorkLeft()
to return * the "wrong message", we can use this.
|
void |
waitStart()
Block a thread until we are started |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.LinkedList tasks
protected boolean started
protected boolean workExpected
protected java.lang.Object cLock
Constructor Detail |
public TaskQueue()
Method Detail |
public java.lang.Runnable getTask() throws java.lang.InterruptedException
getTask
in interface TaskSource
java.lang.InterruptedException
- when the running task gets interrupted.public void addTask(java.lang.Runnable r)
public void setWorkExpected(boolean workExpected)
isWorkLeft()
to return * the "wrong message", we can use this.
TaskQueue tq = new TaskQueue(...) tq.setWorkExpected(true); ....But one must not fail to call
tq.setWorkExpected(false);when no feeds are expected any more, since, otherwise
isWorkLeft()
will return true forever!
public boolean isStarted()
isStarted
in interface TaskSource
public boolean isWorkLeft()
isWorkLeft
in interface TaskSource
public void waitStart() throws java.lang.InterruptedException
TaskSource
waitStart
in interface TaskSource
java.lang.InterruptedException
- when the running task gets interrupted.
|
Spieleck | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |