public class BasicExecutionManager extends java.lang.Object implements ExecutionManager
Constructor and Description |
---|
BasicExecutionManager(java.lang.String contextid) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ExecutionListener listener) |
java.util.Collection<Task<?>> |
allTasksLive()
live view of all tasks, for internal use only
|
boolean |
clearTaskSchedulerForTag(java.lang.Object tag)
Forgets that any scheduler was associated with a tag.
|
void |
deleteTag(java.lang.Object tag)
Deletes the given tag, including all tasks using this tag.
|
void |
deleteTask(Task<?> task) |
java.util.List<Task<?>> |
getAllTasks()
not on interface because potentially expensive
|
long |
getNumActiveTasks()
count of tasks started but not ended
|
long |
getNumIncompleteTasks()
count of tasks submitted but not ended
|
long |
getNumInMemoryTasks()
count of tasks kept in memory, often including ended tasks
|
static java.lang.ThreadLocal<Task<?>> |
getPerThreadCurrentTask() |
java.util.concurrent.ConcurrentMap<java.lang.Object,TaskScheduler> |
getSchedulerByTag() |
Task<?> |
getTask(java.lang.String id)
returns the task with the given ID, or null if none
|
TaskScheduler |
getTaskSchedulerForTag(java.lang.Object tag) |
java.util.Set<Task<?>> |
getTasksWithAllTags(java.lang.Iterable<?> tags)
only works with at least one tag; returns empty if no tags
|
java.util.Set<Task<?>> |
getTasksWithAnyTag(java.lang.Iterable<?> tags)
returns all tasks that have any of the given tags (immutable)
|
java.util.Set<Task<?>> |
getTasksWithTag(java.lang.Object tag)
returns all tasks with the given tag (immutable)
|
java.util.Set<java.lang.Object> |
getTaskTags()
returns all tags known to this manager (immutable)
|
long |
getTotalTasksSubmitted()
count of all tasks submitted
|
boolean |
isShutdown() |
void |
removeListener(ExecutionListener listener) |
<T> Task<T> |
scheduleWith(java.util.Map<?,?> flags,
Task<T> task) |
<T> Task<T> |
scheduleWith(Task<T> task) |
void |
setTaskSchedulerForTag(java.lang.Object tag,
java.lang.Class<? extends TaskScheduler> scheduler) |
void |
setTaskSchedulerForTag(java.lang.Object tag,
TaskScheduler scheduler)
Defines a
TaskScheduler to run on all subsequently submitted jobs with the given tag. |
void |
shutdownNow() |
<T> Task<T> |
submit(java.util.concurrent.Callable<T> c)
|
<T> Task<T> |
submit(java.util.Map<?,?> flags,
java.util.concurrent.Callable<T> c)
|
Task<?> |
submit(java.util.Map<?,?> flags,
java.lang.Runnable r)
|
<T> Task<T> |
submit(java.util.Map<?,?> flags,
TaskAdaptable<T> task)
Submits the given
Task for execution in the context associated with this manager. |
Task<?> |
submit(java.lang.Runnable r)
|
<T> Task<T> |
submit(TaskAdaptable<T> t)
|
java.util.Set<Task<?>> |
tasksWithTagLiveOrNull(java.lang.Object tag)
exposes live view, for internal use only
|
public static java.lang.ThreadLocal<Task<?>> getPerThreadCurrentTask()
public void shutdownNow()
public void addListener(ExecutionListener listener)
public void removeListener(ExecutionListener listener)
public void deleteTag(java.lang.Object tag)
public void deleteTask(Task<?> task)
public boolean isShutdown()
isShutdown
in interface ExecutionManager
public long getTotalTasksSubmitted()
public long getNumIncompleteTasks()
public long getNumActiveTasks()
public long getNumInMemoryTasks()
@Beta public java.util.Set<Task<?>> tasksWithTagLiveOrNull(java.lang.Object tag)
public Task<?> getTask(java.lang.String id)
ExecutionManager
getTask
in interface ExecutionManager
public java.util.List<Task<?>> getAllTasks()
public java.util.Set<Task<?>> getTasksWithTag(java.lang.Object tag)
ExecutionManager
getTasksWithTag
in interface ExecutionManager
public java.util.Set<Task<?>> getTasksWithAnyTag(java.lang.Iterable<?> tags)
ExecutionManager
getTasksWithAnyTag
in interface ExecutionManager
public java.util.Set<Task<?>> getTasksWithAllTags(java.lang.Iterable<?> tags)
getTasksWithAllTags
in interface ExecutionManager
@Beta public java.util.Collection<Task<?>> allTasksLive()
public java.util.Set<java.lang.Object> getTaskTags()
ExecutionManager
getTaskTags
in interface ExecutionManager
public Task<?> submit(java.lang.Runnable r)
ExecutionManager
submit
in interface ExecutionManager
public Task<?> submit(java.util.Map<?,?> flags, java.lang.Runnable r)
ExecutionManager
submit
in interface ExecutionManager
public <T> Task<T> submit(java.util.concurrent.Callable<T> c)
ExecutionManager
submit
in interface ExecutionManager
public <T> Task<T> submit(java.util.Map<?,?> flags, java.util.concurrent.Callable<T> c)
ExecutionManager
submit
in interface ExecutionManager
public <T> Task<T> submit(TaskAdaptable<T> t)
ExecutionManager
submit
in interface ExecutionManager
public <T> Task<T> submit(java.util.Map<?,?> flags, TaskAdaptable<T> task)
ExecutionManager
Task
for execution in the context associated with this manager.
The following optional flags supported (in the optional map first arg):
Collection
of object tags each of which the task should be associated,
used for associating with contexts, mutex execution, and other purposes
Collection
of strings, representing a category on which an object should own a synch lock
Collection
of strings, representing a category on which an object should own a synch lock
Closure
that will be invoked just before the task starts if it starts as a result of this call
Closure
that will be invoked when the task completes if it starts as a result of this call
Closure
it is passed the task for convenience. The closure can be any of the
following types; either a Closure
, Runnable
or Callable
.
If a Map is supplied it must be modifiable (currently; may allow immutable maps in future).
submit
in interface ExecutionManager
public TaskScheduler getTaskSchedulerForTag(java.lang.Object tag)
public void setTaskSchedulerForTag(java.lang.Object tag, java.lang.Class<? extends TaskScheduler> scheduler)
public void setTaskSchedulerForTag(java.lang.Object tag, TaskScheduler scheduler)
TaskScheduler
to run on all subsequently submitted jobs with the given tag.
Maximum of one allowed currently. Resubmissions of the same scheduler (or scheduler class)
allowed. If changing, you must call clearTaskSchedulerForTag(Object)
between the two.public boolean clearTaskSchedulerForTag(java.lang.Object tag)
public java.util.concurrent.ConcurrentMap<java.lang.Object,TaskScheduler> getSchedulerByTag()