edu.rice.cs.plt.concurrent
Class ExecutorIncrementalTaskController<I,R>

java.lang.Object
  extended by edu.rice.cs.plt.concurrent.TaskController<R>
      extended by edu.rice.cs.plt.concurrent.IncrementalTaskController<I,R>
          extended by edu.rice.cs.plt.concurrent.ExecutorIncrementalTaskController<I,R>
All Implemented Interfaces:
ResolvingThunk<R>, Thunk<R>, Future<R>

public class ExecutorIncrementalTaskController<I,R>
extends IncrementalTaskController<I,R>

A TaskController for an IncrementalTask, which is scheduled for execution by an Executor. To support canceling, the task should respond to an interrupt by throwing an InterruptedException, wrapped by a WrappedException. The task is submitted (via Executor.execute(java.lang.Runnable)) when start() is invoked (if the executor blocks, so will start()); its status is changed to "running" when it actually begins executing; if canceled in the interim, the status will still be "paused" until the task begins its scheduled execution.


Nested Class Summary
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.concurrent.IncrementalTaskController
IncrementalTaskController.CanceledPausingState, IncrementalTaskController.FreshPausingState, IncrementalTaskController.PausedStartingState, IncrementalTaskController.PausedState, IncrementalTaskController.PausingState, IncrementalTaskController.StartedPausingState
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.concurrent.TaskController
TaskController.CanceledStartingState, TaskController.CanceledState, TaskController.CancelingState, TaskController.CleanlyFinishedState, TaskController.ComputingState, TaskController.ExecutionExceptionState, TaskController.FinishedState, TaskController.FreshStartingState, TaskController.FreshState, TaskController.InternalExceptionState, TaskController.RunningState, TaskController.StartingState, TaskController.State, TaskController.Status, TaskController.WaitingState
 
Field Summary
 
Fields inherited from class edu.rice.cs.plt.concurrent.TaskController
state
 
Constructor Summary
ExecutorIncrementalTaskController(Executor executor, IncrementalTask<? extends I,? extends R> task, boolean ignoreIntermediate)
           
 
Method Summary
protected  void discard()
          Clean up after the task has completed.
protected  void doPause()
          Pause computation and call IncrementalTaskController.paused().
protected  void doResume()
          Resume computation (after a pause) and call TaskController.started().
protected  void doStart()
          Begin computation and call TaskController.started().
protected  void doStop()
          Terminate computation and call TaskController.stopped().
 
Methods inherited from class edu.rice.cs.plt.concurrent.IncrementalTaskController
intermediateListeners, intermediateQueue, pause, paused, stepped, steps
 
Methods inherited from class edu.rice.cs.plt.concurrent.TaskController
attemptGet, attemptGet, cancel, cancel, 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

ExecutorIncrementalTaskController

public ExecutorIncrementalTaskController(Executor executor,
                                         IncrementalTask<? extends I,? extends R> task,
                                         boolean ignoreIntermediate)
Method Detail

doStart

protected void doStart()
Description copied from class: TaskController
Begin computation and call TaskController.started(). If starting does not occur immediately (for example, blocking occurs first), the started() call may occur in a different thread.

Specified by:
doStart in class TaskController<R>

doPause

protected void doPause()
Description copied from class: IncrementalTaskController
Pause computation and call IncrementalTaskController.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.

Specified by:
doPause in class IncrementalTaskController<I,R>

doResume

protected void doResume()
Description copied from class: IncrementalTaskController
Resume computation (after a pause) and call TaskController.started(). If starting does not occur immediately (for example, blocking occurs first), the started() call may occur in a different thread.

Specified by:
doResume in class IncrementalTaskController<I,R>

doStop

protected void doStop()
Description copied from class: TaskController
Terminate computation and call TaskController.stopped(). Never called before started() has been invoked. If termination does not occur immediately (for example, blocking occurs first), the stopped() call may occur in a different thread.

Specified by:
doStop in class TaskController<R>

discard

protected void discard()
Description copied from class: TaskController
Clean up after the task has completed. Called whenever the task enters a canceled or finished state (for example, when finishedCleanly() has been called, or when cancel() is invoked on a PAUSED controller). By default, does nothing, but can be overridden to close connections or throw away unnecessary objects. (Where TaskControllers live far beyond their computation life span (as simple wrappers for a value), this allows objects related to the computation to be garbage-collected in the interim.)

Overrides:
discard in class TaskController<R>