T - identifies that interface as one that defines task methodspublic interface TaskInterface<T>
interface IDelay implements TaskInterface<IDelay> {
public void exec(...);
}
class Delay implements IDelay {...}
Note that Delay or IDelay can implement/extend other interfaces, but among all of them only one should be designated as a TaskInterface in the manner above.
There are no methods to implement from this interface, but it does provide several common methods on tasks. It also allows the BT task-dependency mechanism to work properly.
| Modifier and Type | Method and Description |
|---|---|
default CompletableFuture<Void> |
complete()
Convenience method for returning a void result.
|
default <R> CompletableFuture<R> |
complete(R arg)
Convenience method creates a CompletableFuture from a constant value, which
may or may not be null.
|
default <R> R |
get(Future<R> future)
Convenience method that calls future.get() but turns any checked exceptions from
that call into unchecked ones.
|
default String |
getName()
Returns the name of this task, useful for logging and profiling.
|
default T |
light()
Forces execution within the outer thread, 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 this task.
|
default T name(String name)
name - to setdefault String getName()
default T light()
Light annotation on a task method.
Reverses any previous call to runSpawned()
default T runSpawned()
Reverses any previous call to light() or any Light annotation
default <R> R get(Future<R> future)
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.