|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--lava.thread.TaskParallelizer
Schedules tasks for parallel execution.
Details: TaskParallelizer
enqueues tasks to be executed and runs them at a moderated rate, making it reasonable for clients to spawn unlimited numbers of threads without concern for overloading the system.
TaskParallelizer
s operates on instances of ITask
, which are similar to Java Runnable
objects, by converting them to Thread
s before enqueuing them.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
TaskParallelizer(int cl)
Sets concurrency limit. |
Method Summary | |
void |
cancel(ITask t)
|
void |
enqueue(ITask t,
int priority)
Enqueues task for execution. |
void |
resumeDispatching()
Allows new tasks to be started. |
void |
run()
Runnable portion of this thread. |
void |
setExitable(boolean e)
No summary available. |
void |
suspendDispatching()
Prevents new tasks from being started. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TaskParallelizer(int cl)
Details: This constructor sets the concurrency limit for parallel task execution, or the maximum number of simultaneously executing threads that this instance will create. Setting this value lower affords more efficient execution; setting this value higher achieves greater parallelization.
Method Detail |
public void setExitable(boolean e)
Details: setExitable sets exitable
, a flag that indicates whether or not this instance will finish its own thread and stop executing tasks once the waiting queue runs empty.
e
- the new value for exitablepublic void run()
run
in class java.lang.Thread
public void enqueue(ITask t, int priority)
Details: enqueue
converts the given ITask
(t) into a Thread
and adds it to the waiting queue for eventual execution. The position within the queue where the task is inserted depends on the indicated priority (priority) and the priority of already enqueued tasks.
t
- the taskpriority
- the enqueuing prioritypublic void cancel(ITask t)
public void suspendDispatching()
Details: suspendDispatching
tells this TaskParallelizer
that no more enqueued tasks should be started until resumeDispatching
is called.
public void resumeDispatching()
Details: resumeDispatching
tells this TaskParallelizer
that it is OK to execute enqueued tasks. This method is typically called some time after suspendDispatching
has been called.
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |