public static class DynamicTasks.TaskQueueingResult<T> extends java.lang.Object implements TaskWrapper<T>
Modifier and Type | Method and Description |
---|---|
T |
andWaitForSuccess()
Blocks for the task to be completed, throwing if there are any errors
and otherwise returning the value.
|
Task<T> |
asTask() |
DynamicTasks.TaskQueueingResult<T> |
executionContext(Entity entity)
as
executionContext(ExecutionContext) but inferring from the entity |
DynamicTasks.TaskQueueingResult<T> |
executionContext(ExecutionContext execContext)
specifies an execContext to use if the task has to be explicitly submitted;
if omitted it will attempt to find one based on the current thread's context
|
Task<T> |
getTask() |
boolean |
isQueuedOrSubmitted()
returns true if the task either is currently queued or has been submitted
|
void |
orCancel() |
DynamicTasks.TaskQueueingResult<T> |
orSubmitAndBlock()
Alternative to
orSubmitAsync() but where, if the submission is needed
(usually because a previous DynamicTasks.queueIfPossible(TaskAdaptable) did not have a queueing context)
it will wait until execution completes (and in fact will execute the task in this thread,
as per ExecutionContext.get(TaskAdaptable) . |
DynamicTasks.TaskQueueingResult<T> |
orSubmitAndBlock(Entity entity)
|
DynamicTasks.TaskQueueingResult<T> |
orSubmitAsync()
Causes the task to be submitted (asynchronously) if it hasn't already been,
such as if a previous
DynamicTasks.queueIfPossible(TaskAdaptable) did not have a queueing context. |
DynamicTasks.TaskQueueingResult<T> |
orSubmitAsync(Entity entity)
Convenience for setting
executionContext(Entity) then orSubmitAsync() . |
boolean |
wasQueued()
returns true if the task was queued
|
public Task<T> asTask()
asTask
in interface TaskAdaptable<T>
public Task<T> getTask()
getTask
in interface TaskWrapper<T>
public boolean wasQueued()
public boolean isQueuedOrSubmitted()
public DynamicTasks.TaskQueueingResult<T> executionContext(ExecutionContext execContext)
public DynamicTasks.TaskQueueingResult<T> executionContext(Entity entity)
executionContext(ExecutionContext)
but inferring from the entitypublic DynamicTasks.TaskQueueingResult<T> orSubmitAsync()
DynamicTasks.queueIfPossible(TaskAdaptable)
did not have a queueing context.
An executionContext(ExecutionContext)
should typically have been set
(or use orSubmitAsync(Entity)
).
public DynamicTasks.TaskQueueingResult<T> orSubmitAsync(Entity entity)
executionContext(Entity)
then orSubmitAsync()
.public DynamicTasks.TaskQueueingResult<T> orSubmitAndBlock()
orSubmitAsync()
but where, if the submission is needed
(usually because a previous DynamicTasks.queueIfPossible(TaskAdaptable)
did not have a queueing context)
it will wait until execution completes (and in fact will execute the task in this thread,
as per ExecutionContext.get(TaskAdaptable)
.
If the task is already queued, this method does nothing, not even blocks, to permit cases where a caller is building up a set of tasks to be executed sequentially: with a queueing context the caller can line them all up, but without that the caller needs this task finished before submitting subsequent tasks.
If blocking is desired in all cases and this call should fail on task failure, invoke andWaitForSuccess()
on the result,
or consider using DynamicTasks.get(TaskAdaptable)
instead of this method,
or DynamicTasks.get(TaskAdaptable, Entity)
if an execuiton context a la orSubmitAndBlock(Entity)
is needed.
public DynamicTasks.TaskQueueingResult<T> orSubmitAndBlock(Entity entity)
public T andWaitForSuccess()
In addition to cases where a result is wanted, this is needed in any context where subsequent commands assume the task has completed. not needed in a context where the task is simply being built up and queued.
public void orCancel()