@Beta
public class DynamicTasks
extends java.lang.Object
TaskQueueingContext
to execute tasks.Modifier and Type | Class and Description |
---|---|
static class |
DynamicTasks.TaskQueueingResult<T> |
Constructor and Description |
---|
DynamicTasks() |
Modifier and Type | Method and Description |
---|---|
static TaskQueueingContext |
drain(Duration optionalTimeout,
boolean throwFirstError)
Calls
TaskQueueingContext.drain(Duration, boolean, boolean) on the current task context |
static <T> T |
get(TaskAdaptable<T> t)
submits/queues the given task if needed, and gets the result (unchecked)
only permitted in a queueing context (ie a DST main job) if the task is not yet submitted
|
static TaskQueueingContext |
getTaskQueuingContext() |
static TaskQueueingContext |
getThreadTaskQueuingContext() |
static void |
markInessential()
same as
Tasks.markInessential()
(but included here for convenience as it is often used in conjunction with DynamicTasks ) |
static <T> Task<T> |
queue(java.lang.String name,
java.util.concurrent.Callable<T> job) |
static <T> Task<T> |
queue(java.lang.String name,
java.lang.Runnable job) |
static void |
queue(TaskAdaptable<?> task1,
TaskAdaptable<?> task2,
TaskAdaptable<?>... tasks) |
static void |
queue(TaskFactory<?> task1,
TaskFactory<?> task2,
TaskFactory<?>... tasks) |
static <T extends TaskAdaptable<?>> |
queue(TaskFactory<T> taskFactory) |
static <V extends TaskAdaptable<?>> |
queue(V task)
Queues the given task.
|
static <T extends TaskAdaptable<?>> |
queueIfNeeded(T task)
queues the task if needed, i.e.
|
static <T> DynamicTasks.TaskQueueingResult<T> |
queueIfPossible(TaskAdaptable<T> task)
Tries to add the task to the current addition context if there is one, otherwise does nothing.
|
static <T> DynamicTasks.TaskQueueingResult<T> |
queueIfPossible(TaskFactory<? extends TaskAdaptable<T>> task) |
static <T> Task<T> |
queueInTaskHierarchy(Task<T> task)
adds the given task to the nearest task addition context,
either set as a thread-local, or in the current task, or the submitter of the task, etc
|
static void |
removeTaskQueueingContext() |
static void |
setTaskQueueingContext(TaskQueueingContext newTaskQC) |
static <T> Task<T> |
submit(TaskAdaptable<T> task,
Entity entity)
queues the task if possible, otherwise submits it asynchronously; returns the task for callers to
Task.getUnchecked() or Task.blockUntilEnded() |
static void |
swallowChildrenFailures()
as
Tasks.swallowChildrenFailures() but requiring a TaskQueueingContext . |
static Task<?> |
waitForLast()
As
drain(Duration, boolean) waiting forever and throwing the first error
(excluding errors in inessential tasks),
then returning the last task in the queue (which is guaranteed to have finished without error,
if this method returns without throwing) |
public static void setTaskQueueingContext(TaskQueueingContext newTaskQC)
public static TaskQueueingContext getThreadTaskQueuingContext()
public static TaskQueueingContext getTaskQueuingContext()
public static void removeTaskQueueingContext()
public static <T> DynamicTasks.TaskQueueingResult<T> queueIfPossible(TaskAdaptable<T> task)
orSubmitAsync()
on the returned
TaskQueueingResult
to handle execution of tasks in a
BasicExecutionContext
.public static <T> DynamicTasks.TaskQueueingResult<T> queueIfPossible(TaskFactory<? extends TaskAdaptable<T>> task)
queueIfPossible(TaskAdaptable)
public static <T> Task<T> queueInTaskHierarchy(Task<T> task)
throws if it cannot add
public static <V extends TaskAdaptable<?>> V queue(V task)
queueIfPossible(TaskAdaptable)
and DynamicTasks.TaskQueueingResult.orSubmitAsync()
if the calling context is a basic task.task
- The task to queuejava.lang.IllegalStateException
- if no task queueing context is availablepublic static void queue(TaskAdaptable<?> task1, TaskAdaptable<?> task2, TaskAdaptable<?>... tasks)
public static <T extends TaskAdaptable<?>> T queue(TaskFactory<T> taskFactory)
public static void queue(TaskFactory<?> task1, TaskFactory<?> task2, TaskFactory<?>... tasks)
public static <T> Task<T> queue(java.lang.String name, java.util.concurrent.Callable<T> job)
public static <T> Task<T> queue(java.lang.String name, java.lang.Runnable job)
public static <T extends TaskAdaptable<?>> T queueIfNeeded(T task)
public static <T> T get(TaskAdaptable<T> t)
public static Task<?> waitForLast()
drain(Duration, boolean)
waiting forever and throwing the first error
(excluding errors in inessential tasks),
then returning the last task in the queue (which is guaranteed to have finished without error,
if this method returns without throwing)public static TaskQueueingContext drain(Duration optionalTimeout, boolean throwFirstError)
TaskQueueingContext.drain(Duration, boolean, boolean)
on the current task context@Beta public static void swallowChildrenFailures()
Tasks.swallowChildrenFailures()
but requiring a TaskQueueingContext
.public static void markInessential()
Tasks.markInessential()
(but included here for convenience as it is often used in conjunction with DynamicTasks
)public static <T> Task<T> submit(TaskAdaptable<T> task, Entity entity)
Task.getUnchecked()
or Task.blockUntilEnded()