public abstract class ForwardingTask<T> extends com.google.common.collect.ForwardingObject implements TaskInternal<T>
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(java.lang.Runnable listener,
java.util.concurrent.Executor executor) |
void |
applyTagModifier(com.google.common.base.Function<java.util.Set<java.lang.Object>,java.lang.Void> modifier) |
Task<T> |
asTask() |
void |
blockUntilEnded()
Causes calling thread to block until the task is ended.
|
boolean |
blockUntilEnded(Duration timeout)
As
Task.blockUntilEnded(), but returning after the given timeout;
true if the task has ended and false otherwise |
void |
blockUntilStarted()
Causes calling thread to block until the task is started.
|
boolean |
blockUntilStarted(Duration timeout) |
boolean |
cancel() |
boolean |
cancel(boolean arg0)
As
Future.cancel(boolean). |
T |
get() |
T |
get(Duration duration)
As
Future.get(long, java.util.concurrent.TimeUnit) |
T |
get(long arg0,
java.util.concurrent.TimeUnit arg1) |
java.lang.String |
getBlockingDetails()
returns a textual message giving details while the task is blocked
|
Task<?> |
getBlockingTask()
returns a task that this task is blocked on
|
java.lang.String |
getDescription() |
java.lang.String |
getDisplayName() |
long |
getEndTimeUtc()
if
Future.isDone() (for any reason) returns the time when the task ended;
guaranteed to be >= Task.getStartTimeUtc() > 0 if ended, or -1 otherwise |
java.lang.Object |
getExtraStatusText() |
java.lang.String |
getId() |
java.util.concurrent.Future<T> |
getInternalFuture()
returns the underlying future where this task's results will come in; see
TaskInternal.initInternalFuture(ListenableFuture) |
java.util.concurrent.Callable<T> |
getJob() |
com.google.common.util.concurrent.ExecutionList |
getListeners() |
java.util.Set<java.lang.Object> |
getMutableTags() |
Task<?> |
getProxyTarget()
if a task is a proxy for another one (used mainly for internal tasks),
this returns the "real" task represented by this one
|
long |
getQueuedTimeUtc()
if the job is queued for submission (e.g.
|
long |
getStartTimeUtc()
if
Task.isBegun() returns the time when the task was starts;
guaranteed to be >= Task.getSubmitTimeUtc() > 0 if started, or -1 otherwise |
java.lang.String |
getStatusDetail(boolean multiline)
Returns detailed status, suitable for a hover.
|
java.lang.String |
getStatusSummary() |
Task<?> |
getSubmittedByTask()
task which submitted this task, if was submitted by a task
|
long |
getSubmitTimeUtc()
if
Task.isSubmitted() returns the time when the task was submitted; or -1 otherwise |
java.util.Set<java.lang.Object> |
getTags() |
java.lang.Thread |
getThread()
The thread where the task is running, if it is running.
|
T |
getUnchecked()
As
Future.get(), but propagating checked exceptions as unchecked for convenience. |
T |
getUnchecked(Duration duration)
As
Future.get(), but propagating checked exceptions as unchecked for convenience
(including a TimeoutException if the duration expires) |
void |
initInternalFuture(com.google.common.util.concurrent.ListenableFuture<T> result)
sets the internal future object used to record the association to a job submitted to an
ExecutorService |
boolean |
isBegun()
Whether task has started running.
|
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
isError()
Whether the task threw an error, including cancellation (implies
Future.isDone()) |
boolean |
isQueued() |
boolean |
isQueuedAndNotSubmitted() |
boolean |
isQueuedOrSubmitted() |
boolean |
isSubmitted()
Whether task has been submitted
Submitted tasks are normally expected to start running then complete,
but unsubmitted tasks are sometimes passed around for someone else to submit them.
|
void |
markQueued()
marks the task as queued for execution
|
void |
resetBlockingDetails() |
void |
resetBlockingTask() |
void |
runListeners() |
java.lang.String |
setBlockingDetails(java.lang.String blockingDetails)
allows a task user to specify why a task is blocked; for use immediately before a blocking/wait,
and typically cleared immediately afterwards; referenced by management api to inspect a task
which is blocking
|
Task<?> |
setBlockingTask(Task<?> blockingTask)
as
TaskInternal.setBlockingDetails(String) but records a task which is blocking,
for use e.g. |
void |
setEndTimeUtc(long val) |
void |
setExtraStatusText(java.lang.Object extraStatus) |
void |
setJob(java.util.concurrent.Callable<T> job) |
void |
setStartTimeUtc(long currentTimeMillis) |
void |
setSubmittedByTask(Task<?> task) |
void |
setSubmitTimeUtc(long currentTimeMillis) |
void |
setThread(java.lang.Thread thread) |
public void addListener(java.lang.Runnable listener,
java.util.concurrent.Executor executor)
addListener in interface com.google.common.util.concurrent.ListenableFuture<T>public boolean cancel(boolean arg0)
TaskFuture.cancel(boolean). Note that Future.isDone() and Task.blockUntilEnded(Duration) return immediately
once a task is cancelled, consistent with the underlying FutureTask behaviour.
TODO Fine-grained control over underlying jobs, e.g. to ensure anything represented by this task is actually completed,
is not (yet) publicly exposed. See the convenience method blockUntilInternalTasksEnded in the Tasks set of helpers
for more discussion.public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic T get(long arg0, java.util.concurrent.TimeUnit arg1) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<T>public boolean isDone()
isDone in interface java.util.concurrent.Future<T>public Task<T> asTask()
asTask in interface TaskAdaptable<T>public long getSubmitTimeUtc()
TaskTask.isSubmitted() returns the time when the task was submitted; or -1 otherwisegetSubmitTimeUtc in interface Task<T>public long getStartTimeUtc()
TaskTask.isBegun() returns the time when the task was starts;
guaranteed to be >= Task.getSubmitTimeUtc() > 0 if started, or -1 otherwisegetStartTimeUtc in interface Task<T>public long getEndTimeUtc()
TaskFuture.isDone() (for any reason) returns the time when the task ended;
guaranteed to be >= Task.getStartTimeUtc() > 0 if ended, or -1 otherwisegetEndTimeUtc in interface Task<T>public java.lang.String getDisplayName()
getDisplayName in interface Task<T>public java.lang.String getDescription()
getDescription in interface Task<T>public Task<?> getSubmittedByTask()
TaskgetSubmittedByTask in interface Task<T>public java.lang.Thread getThread()
Taskpublic boolean isSubmitted()
TaskisSubmitted in interface Task<T>public boolean isBegun()
Taskpublic boolean isError()
TaskFuture.isDone())public void blockUntilStarted()
TaskblockUntilStarted in interface Task<T>public void blockUntilEnded()
TaskEither normally or by cancellation or error, but without throwing error on cancellation or error. (Errors are logged at debug.)
blockUntilEnded in interface Task<T>public boolean blockUntilEnded(Duration timeout)
TaskTask.blockUntilEnded(), but returning after the given timeout;
true if the task has ended and false otherwiseblockUntilEnded in interface Task<T>public java.lang.String getStatusSummary()
getStatusSummary in interface Task<T>public java.lang.String getStatusDetail(boolean multiline)
TaskgetStatusDetail in interface Task<T>public T get(Duration duration) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
TaskFuture.get(long, java.util.concurrent.TimeUnit)public T getUnchecked()
TaskFuture.get(), but propagating checked exceptions as unchecked for convenience.getUnchecked in interface Task<T>public T getUnchecked(Duration duration)
TaskFuture.get(), but propagating checked exceptions as unchecked for convenience
(including a TimeoutException if the duration expires)getUnchecked in interface Task<T>public void initInternalFuture(com.google.common.util.concurrent.ListenableFuture<T> result)
TaskInternalExecutorServiceinitInternalFuture in interface TaskInternal<T>public long getQueuedTimeUtc()
TaskInternalgetQueuedTimeUtc in interface TaskInternal<T>public java.util.concurrent.Future<T> getInternalFuture()
TaskInternalTaskInternal.initInternalFuture(ListenableFuture)getInternalFuture in interface TaskInternal<T>public boolean isQueued()
isQueued in interface TaskInternal<T>public boolean isQueuedOrSubmitted()
isQueuedOrSubmitted in interface TaskInternal<T>public boolean isQueuedAndNotSubmitted()
isQueuedAndNotSubmitted in interface TaskInternal<T>public void markQueued()
TaskInternalmarkQueued in interface TaskInternal<T>public boolean cancel()
cancel in interface TaskInternal<T>public boolean blockUntilStarted(Duration timeout)
blockUntilStarted in interface TaskInternal<T>public java.lang.String setBlockingDetails(java.lang.String blockingDetails)
TaskInternalreturns previous details, in case caller wishes to recall and restore it (e.g. if it is doing a sub-blocking)
setBlockingDetails in interface TaskInternal<T>public Task<?> setBlockingTask(Task<?> blockingTask)
TaskInternalTaskInternal.setBlockingDetails(String) but records a task which is blocking,
for use e.g. in a gui to navigate to the current active subtask
returns previous blocking task, in case caller wishes to recall and restore it
setBlockingTask in interface TaskInternal<T>public void resetBlockingDetails()
resetBlockingDetails in interface TaskInternal<T>public void resetBlockingTask()
resetBlockingTask in interface TaskInternal<T>public java.lang.String getBlockingDetails()
TaskInternalgetBlockingDetails in interface TaskInternal<T>public Task<?> getBlockingTask()
TaskInternalgetBlockingTask in interface TaskInternal<T>public void setExtraStatusText(java.lang.Object extraStatus)
setExtraStatusText in interface TaskInternal<T>public java.lang.Object getExtraStatusText()
getExtraStatusText in interface TaskInternal<T>public void runListeners()
runListeners in interface TaskInternal<T>public void setEndTimeUtc(long val)
setEndTimeUtc in interface TaskInternal<T>public void setThread(java.lang.Thread thread)
setThread in interface TaskInternal<T>public java.util.concurrent.Callable<T> getJob()
getJob in interface TaskInternal<T>public void setJob(java.util.concurrent.Callable<T> job)
setJob in interface TaskInternal<T>public com.google.common.util.concurrent.ExecutionList getListeners()
getListeners in interface TaskInternal<T>public void setSubmitTimeUtc(long currentTimeMillis)
setSubmitTimeUtc in interface TaskInternal<T>public void setSubmittedByTask(Task<?> task)
setSubmittedByTask in interface TaskInternal<T>public java.util.Set<java.lang.Object> getMutableTags()
getMutableTags in interface TaskInternal<T>public void setStartTimeUtc(long currentTimeMillis)
setStartTimeUtc in interface TaskInternal<T>public void applyTagModifier(com.google.common.base.Function<java.util.Set<java.lang.Object>,java.lang.Void> modifier)
applyTagModifier in interface TaskInternal<T>public Task<?> getProxyTarget()
TaskInternalgetProxyTarget in interface TaskInternal<T>