public interface ExecutionContext
extends java.util.concurrent.Executor
Executor
.
The "context" could, for example, be an Entity
so that tasks executed
can be annotated as executing in that context.Modifier and Type | Method and Description |
---|---|
<T> T |
get(TaskAdaptable<T> task)
Efficient implementation of common case when
submit(TaskAdaptable) is followed by an immediate Task#get() . |
<T> Maybe<T> |
getImmediately(java.lang.Object callableOrSupplierOrTaskFactory)
Gets the value promptly, or returns
Maybe.absent() if the value is not yet available. |
<T> Maybe<T> |
getImmediately(Task<T> task)
Deprecated.
since 1.0.0; this can cause the task to be interrupted/cancelled, such that subsequent
use of
task.get() will fail (if the value was not resolved immediately previously).
It is only safe to call this if the the given task is for a one-off usage (not expected
to be used again later). Consider supplying a TaskFactory if this tasks's
Task.cancel(boolean) is problematic, or consider other utilities
(such as ValueResolver with immediate(true) in the brooklyn-core project). |
java.util.Set<Task<?>> |
getTasks()
Get the tasks executed through this context (returning an immutable set).
|
boolean |
isShutdown() |
<T> Task<T> |
submit(java.util.concurrent.Callable<T> callable)
Deprecated.
since 1.0.0 pass a display name or a more detailed map
|
<T> Task<T> |
submit(java.util.Map<?,?> properties,
java.util.concurrent.Callable<T> callable)
See
ExecutionManager.submit(Map, TaskAdaptable) for properties that can be passed in. |
Task<?> |
submit(java.util.Map<?,?> properties,
java.lang.Runnable runnable)
See
ExecutionManager.submit(Map, TaskAdaptable) for properties that can be passed in. |
<T> Task<T> |
submit(java.util.Map<?,?> properties,
TaskAdaptable<T> task)
See
ExecutionManager.submit(Map, TaskAdaptable) for properties that can be passed in. |
Task<?> |
submit(java.lang.Runnable runnable)
Deprecated.
since 1.0.0 pass a display name or a more detailed map
|
<T> Task<T> |
submit(java.lang.String displayName,
java.util.concurrent.Callable<T> callable)
{@link ExecutionManager#submit(String, Callable)
|
Task<?> |
submit(java.lang.String displayName,
java.lang.Runnable runnable)
{@link ExecutionManager#submit(String, Runnable)
|
<T> Task<T> |
submit(TaskAdaptable<T> task)
|
java.util.Set<Task<?>> getTasks()
Task<?> submit(java.util.Map<?,?> properties, java.lang.Runnable runnable)
ExecutionManager.submit(Map, TaskAdaptable)
for properties that can be passed in.<T> Task<T> submit(java.util.Map<?,?> properties, java.util.concurrent.Callable<T> callable)
ExecutionManager.submit(Map, TaskAdaptable)
for properties that can be passed in.@Deprecated Task<?> submit(java.lang.Runnable runnable)
@Deprecated <T> Task<T> submit(java.util.concurrent.Callable<T> callable)
Task<?> submit(java.lang.String displayName, java.lang.Runnable runnable)
<T> Task<T> submit(java.lang.String displayName, java.util.concurrent.Callable<T> callable)
<T> Task<T> submit(TaskAdaptable<T> task)
<T> Task<T> submit(java.util.Map<?,?> properties, TaskAdaptable<T> task)
ExecutionManager.submit(Map, TaskAdaptable)
for properties that can be passed in.boolean isShutdown()
<T> Maybe<T> getImmediately(java.lang.Object callableOrSupplierOrTaskFactory)
Maybe.absent()
if the value is not yet available.
It may throw an error if it cannot be determined whether a value is available immediately or not.
Implementations will typically act like get(TaskAdaptable)
with additional
tricks to attempt to be non-blocking, such as recognizing some "immediate" markers.
Supports Callable
, Runnable
, Supplier
, and TaskFactory
argument types.
Passing in Task
is deprecated and discouraged - see getImmediately(Task)
.
<T> Maybe<T> getImmediately(Task<T> task)
task.get()
will fail (if the value was not resolved immediately previously).
It is only safe to call this if the the given task is for a one-off usage (not expected
to be used again later). Consider supplying a TaskFactory
if this tasks's
Task.cancel(boolean)
is problematic, or consider other utilities
(such as ValueResolver with immediate(true) in the brooklyn-core project).getImmediately(Object)
but strongly typed for a task.<T> T get(TaskAdaptable<T> task)
submit(TaskAdaptable)
is followed by an immediate Task#get()
.
This is efficient in that it may typically attempt to execute in the current thread,
with appropriate configuration to make it look like it is in a sub-thread,
ie registering this as a task and allowing context methods on tasks to see the given sub-task.
However it will normally be non-blocking which reduces overhead and
is permissible within a getImmediately(Object)
task
If the argument has already been submitted it simply blocks on it
(i.e. no additional execution, and in that case would fail within a getImmediately(Object)
).
task
- the task whose result is being sought