|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.concurrent.TaskController<R>
edu.rice.cs.plt.concurrent.IncrementalTaskController<I,R>
public abstract class IncrementalTaskController<I,R>
Provides access to a concurrent task that produces incremental results. Adds
a pause() method, more responsive cancellation, and access to intermediate computation
results via steps() and intermediateQueue().
To implement a concrete instance, a subclass must provide TaskController.doStart(), doPause(),
TaskController.doStop(), and, optionally, TaskController.discard().
| Nested Class Summary | |
|---|---|
protected class |
IncrementalTaskController.CanceledPausingState
A PausingState that has been canceled while waiting for the pause to complete. |
protected class |
IncrementalTaskController.FreshPausingState
Simple instance of PausingState. |
protected class |
IncrementalTaskController.PausedStartingState
A StartingState that has been paused while waiting for startup to complete. |
protected class |
IncrementalTaskController.PausedState
The tasked has been started and then paused. |
protected class |
IncrementalTaskController.PausingState
pause() has been invoked on a RunningState, but the task has not yet paused. |
protected class |
IncrementalTaskController.StartedPausingState
A PausingState that has been started while waiting for the pause to complete. |
| Field Summary |
|---|
| Fields inherited from class edu.rice.cs.plt.concurrent.TaskController |
|---|
state |
| Constructor Summary | |
|---|---|
protected |
IncrementalTaskController()
Sets ignoreIntermediate to false. |
protected |
IncrementalTaskController(boolean ignoreIntermediate)
If ignoreIntermediate, intermediate results will not be enqueued. |
| Method Summary | |
|---|---|
protected abstract void |
doPause()
Pause computation and call paused(). |
protected abstract void |
doResume()
Resume computation (after a pause) and call TaskController.started(). |
ListenerSet.Sink |
intermediateListeners()
Access the ListenerSet responding to the availability of intermediate results. |
BlockingQueue<I> |
intermediateQueue()
Get the queue for storing intermediate results. |
void |
pause()
Request that the task be paused. |
protected void |
paused()
|
protected void |
stepped(I intermediateResult)
Record an intermediate result. |
int |
steps()
Get the number of intermediate steps the task has taken. |
| Methods inherited from class edu.rice.cs.plt.concurrent.TaskController |
|---|
attemptGet, attemptGet, cancel, cancel, discard, doStart, doStop, finishedCleanly, finishedWithImplementationException, finishedWithTaskException, finishListeners, get, get, get, hasValue, isCanceled, isCancelled, isDone, isResolved, runningState, start, started, status, stopped, value |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected IncrementalTaskController()
ignoreIntermediate to false.
protected IncrementalTaskController(boolean ignoreIntermediate)
ignoreIntermediate, intermediate results will not be enqueued. (They will,
however, be passed to any listeners and counted by steps().)
| Method Detail |
|---|
public int steps()
storeIntermediate, at
least this many values have been added to the intermediateQueue.
public BlockingQueue<I> intermediateQueue()
Get the queue for storing intermediate results. Throws an exception if storeIntermediate
is false; otherwise each intermediate result is added to this queue. Clients can check
the controller's status to determine if no additional results will be enqueued. However, there
is no guarantee (in general) that a running task will produce an intermediate result before completing.
(The task being run may follow some convention for indicating termination via the queue.) While the
result is intended to be used only for read operations, given the lack of a nice interface for
separating queue reads from queue writes, the result allows write access to the queue as well.
IncrementalTaskController implementations should invoke stepped(I) to add items to
the queue, rather than doing so directly.
IllegalStateException - If storeIntermediate is false.public ListenerSet.Sink intermediateListeners()
public void pause()
TaskController.start() is invoked. If the the task is PAUSED or FINISHED, has no effect.
CancellationException - If the task is CANCELED.protected abstract void doPause()
paused(). If pausing does not occur immediately, the paused()
call may occur in a different thread. Will only be called after started() has been invoked.
When execution should resume again, doStart() will be invoked (but only after paused()
has been called). In order to support responsive canceling, a call to doStop() may occur
concurrently, or before paused() is called.
protected abstract void doResume()
TaskController.started(). If starting does not occur immediately
(for example, blocking occurs first), the started() call may occur in a different thread.
protected void paused()
protected void stepped(I intermediateResult)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||