|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--distrit.server.FineGrainedInteractiveTasks
Provides an abstraction to run many interactive tasks concurrently so that if one stops before others it can be replaced by a new task. It also enables tasks to be replaced at any time by the server.
This is achieved by the server being informed of which tasks are still alive when it calls the get method and by the server sending out the same or new tasks through the set method. If the same task as the current one is sent then it is ignored. WARNING: Task equality is based on the toString() method.
If a task is sent that the client has previously completed there is an option to ignore this task, but the current implementation will run this task anyway since in many cases this is not a useless functionality. To reenable this option see line marked with **!!.
This assumes InteractiveTask implementations will be well behaved and check their currentThread.isInterrupted() method.
Field Summary | |
static int |
CONTROL_INDEX
Index within the Vector sent to the set method of this task for which task control information is sent. |
static int |
DATA_INDEX
Index within the Vector sent to the set method of this task for which task data information is sent. |
Constructor Summary | |
FineGrainedInteractiveTasks()
Creates new FineGrainedInteractiveTasks |
|
FineGrainedInteractiveTasks(java.util.Vector tasks)
Creates new FineGrainedInteractiveTasks |
Method Summary | |
java.lang.Object |
get(java.lang.Object params)
Used to get output from the tasks plus a Boolean saying if they're alive. |
java.lang.Object |
run(java.lang.Object params)
Starts all tasks in their own thread |
void |
set(java.lang.Object paramsAndWhat)
Used to send input to each of the tasks or to replace these tasks. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CONTROL_INDEX
public static final int DATA_INDEX
Constructor Detail |
public FineGrainedInteractiveTasks()
public FineGrainedInteractiveTasks(java.util.Vector tasks)
tasks
- Method Detail |
public java.lang.Object get(java.lang.Object params)
get
in interface InteractiveTask
params
- can be null if this task doesn't need to know WHAT it has to outputpublic void set(java.lang.Object paramsAndWhat)
set
in interface InteractiveTask
paramsAndWhat
- must be a vector of (Object, InteractiveTask) pairs (vector of 2)
with what must be sent to each task and a new task if necesary.public java.lang.Object run(java.lang.Object params) throws java.lang.InterruptedException
run
in interface Task
params
- Vector containing initial parameters to send to each run method
of encapsulated tasksjava.lang.InterruptedException
- If any task is interruped.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |