V - the type of the result of the CancelableFunctionpublic interface CancelableFunction<V>
CancellationToken. There is no constraint on what an implementation
of CancelableFunction may do, it must implement its sole
execute method do whatever task it
wishes.
How a task must respond to cancellation requests is implementation dependent
but it may always terminate by throwing an
OperationCanceledException.
CancelableFunction is completely
implementation dependent, so in general they does not need to be thread-safe.
CancelableFunction is not required to be
synchronization transparent.CancelableTask,
TaskExecutorService| Modifier and Type | Method and Description |
|---|---|
V |
execute(CancellationToken cancelToken)
Executes the the implementation dependent task and returns the result of
the computation.
|
V execute(CancellationToken cancelToken) throws Exception
CancellationToken to detect cancellation requests and return
immediately or throw an
OperationCanceledException.cancelToken - the CancellationToken which can be checked
periodically by this task to detect cancellation requests. This
argument cannot be null.null.OperationCanceledException - thrown if the task
detects that it was canceled (usually by checking the provided
CancellationToken)Exception - tasks may throw an exception they cannot handle. The
executor should usually log these exceptions as severe problems.