|
| FutureTask (Callable< T > *callable, bool takeOwnership=true) |
| Creates a FutureTask instance that will, upon running, execute the given Callable. More...
|
|
| FutureTask (decaf::lang::Runnable *runnable, const T &result, bool takeOwnership=true) |
| Creates a FutureTask that will, upon running, execute the given Runnable, and arrange that the get method will return the given result on successful completion. More...
|
|
virtual | ~FutureTask () |
|
virtual bool | isCancelled () const |
| Returns true if this task was canceled before it completed normally. More...
|
|
virtual bool | isDone () const |
| Returns true if this task completed. More...
|
|
virtual bool | cancel (bool mayInterruptIfRunning) |
| Attempts to cancel execution of this task. More...
|
|
virtual T | get () |
| Waits if necessary for the computation to complete, and then retrieves its result. More...
|
|
virtual T | get (long long timeout, const TimeUnit &unit) |
| Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. More...
|
|
FutureTask< T > * | clone () |
|
virtual void | done () |
| Protected method invoked when this task transitions to state isDone (whether normally or via cancellation). More...
|
|
virtual void | set (const T &result) |
| Sets the result of this Future to the given value unless this future has already been set or has been cancelled. More...
|
|
virtual void | setException (const decaf::lang::Exception &error) |
| Causes this future to report an ExecutionException with the given Exception as its cause, unless this Future has already been set or has been canceled. More...
|
|
virtual void | run () |
| Run method - called by the Thread class in the context of the thread. More...
|
|
virtual bool | runAndReset () |
| Executes the computation without setting its result, and then resets this Future to initial state, failing to do so if the computation encounters an exception or is canceled. More...
|
|
| FutureTask (const FutureTask< T > &source) |
|
FutureTask< T > & | operator= (const FutureTask< T > &source) |
|
virtual | ~RunnableFuture () |
|
virtual | ~Future () |
|
virtual | ~FutureType () |
|
virtual | ~Runnable () |
|
template<typename T>
class decaf::util::concurrent::FutureTask< T >
A cancellable asynchronous computation.
This class provides a base implementation of Future, with methods to start and cancel a computation, query to see if the computation is complete, and retrieve the result of the computation. The result can only be retrieved when the computation has completed; the get method will block if the computation has not yet completed. Once the computation has completed, the computation cannot be restarted or canceled.
A FutureTask can be used to wrap a Callable or Runnable object. Because FutureTask implements Runnable, a FutureTask can be submitted to an Executor for execution.
In addition to serving as a stand-alone class, this class provides protected functionality that may be useful when creating customized task classes.
- Since
- 1.0
Attempts to cancel execution of this task.
This attempt will fail if the task has already completed, has already been canceled, or could not be canceled for some other reason. If successful, and this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in an attempt to stop the task.
After this method returns, subsequent calls to isDone() will always return true. Subsequent calls to isCancelled() will always return true if this method returned true.
- Parameters
-
mayInterruptIfRunning | True if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete. |
- Returns
- false if the task could not be canceled, typically because it has already completed normally; true otherwise
Implements decaf::util::concurrent::FutureType.