T - identifies that interface that defines task methodspublic interface TaskInterface<T>
interface IDelay implements TaskInterface<IDelay> {
// Add test methods here
}
class Delay implements IDelay {...}
Task classes such as Delay or its interface IDelay above can implement/extend other
interfaces, but among all of them only one should be designated as argument to TaskInterface in the manner above.
There are no required methods to implement from this interface since all have default implementations. For uncommon cases some of these methods may usefully be overridden as noted in each javadoc. Several convenience methods are also provided for wrapping and unwrapping values in/from CompletableFutures. There use is completely optional.
Orchestrator.task(TaskInterface)| Modifier and Type | Method and Description |
|---|---|
default T |
activate()
Forces immediate activation of task methods instead of the default behavior which is that task methods
are only lazily activated according to the rules described in
Orchestrator.task(TaskInterface). |
default CompletableFuture<Void> |
complete()
Convenience method for subclasses that return a void result.
|
default <R> CompletableFuture<R> |
complete(R arg)
Convenience method for subclasses that creates a CompletableFuture from a constant value,
which may or may not be null.
|
default <R> R |
get(CompletableFuture<R> future)
Convenience method for subclasses for accessing a CompletableFuture argument.
|
default String |
getName()
Returns the name of this task, useful for logging and profiling.
|
default boolean |
isActivate()
Indicates that task methods should be activated immediately.
|
default boolean |
isLight()
Indicates the default weight of task methods that do not have a
Light
annotation. |
default boolean |
isRunSpawned()
Indicates that task methods should have threads spawned for them.
|
default T |
light()
Forces inline execution of task methods on this object, i.e.
|
default T |
name(String name)
Provides a name for this task, useful for logging and profiling.
|
default T |
runSpawned()
Forces a new thread to be allocated for task methods on this class, which can be useful to keep the calling
thread free for other purposes.
|
default T name(String name)
Orchestrator.task(TaskInterface), already support this method which
therefore works in expressions like $.task(myTask).name("myTask").myMethod().
That is the typical usage, so there is normally no need to override this method, but subclasses can
override if desired to also enable invocation directly on the task, e.g.
$.task(myTask.name("myTask")).myMethod()name - to setdefault String getName()
default T light()
Orchestrator might otherwise do so.
TaskWrappers (as returned by Orchestrator.task(TaskInterface), already support this method which
therefore works in expressions like $.task(myTask).light().myMethod()
That is the typical usage, so there is normally no need to override this method, but subclasses can
override if desired to also enable invocation directly on the task, e.g.
$.task(myTask.light()).myMethod().
This call reverses any previous call to runSpawned(). The impact of this call is redundant for
task methods that already have Light annotation.
default boolean isLight()
Light
annotation.default T runSpawned()
Orchestrator.task(TaskInterface), already support this method which
therefore works in expressions like $.task(myTask).runSpawned().myMethod().
That is the typical usage, so there is normally no need to override this method, but subclasses can
override if desired to also enable invocation directly on the task, e.g.
$.task(myTask.runSpawned()).myMethod()
This call reverses any previous call to light(). Its effect is superseded by a
Light annotation on a task method if present.
default boolean isRunSpawned()
default T activate()
Orchestrator.task(TaskInterface).
TaskWrappers (as returned by Orchestrator.task(TaskInterface), already support this method which
therefore works in expressions like $.task(myTask).activate(true).myMethod().
That is the typical usage, so there is normally no need to override this method, but subclasses can
override if desired to also enable invocation directly on the task, e.g.
$.task(myTask.activate(true)).myMethod()default boolean isActivate()
default <R> R get(CompletableFuture<R> future)
CompletionExceptions in a more useful than is provided by calling
the standard CompletableFuture.join() operation.R - type of value returnedfuture - to retrieve value fromdefault <R> CompletableFuture<R> complete(R arg)
R - type of value returnedarg - value to wrapdefault CompletableFuture<Void> complete()
Copyright © 2021. All rights reserved.