@AutoFinal @CompileStatic class AwaitablePromiseFactory extends AbstractPromiseFactory
A PromiseFactory built on Groovy's groovy.concurrent API.
Tasks run through Awaitable, unfulfilled promises are DataflowVariable
instances, and lists of promises are combined with Awaitable.all. Without an explicit
executor, tasks are submitted to the executor Groovy uses for async blocks,
Awaitable.getExecutor, which is a virtual-thread executor on Java 21 and later.
Both direct and chained get() calls report failures as java.util.concurrent.ExecutionException
with the original failure as the cause. Error callbacks receive the original failure. A single-promise
onError recovers with its callback result; the aggregate onError observes the failure
and leaves the returned promise failed.
| Fields inherited from class | Fields |
|---|---|
class AbstractPromiseFactory |
lookupStrategies |
| Type | Name and description |
|---|---|
java.util.concurrent.Executor |
executorThe executor tasks are submitted to, or null to use Awaitable.getExecutor
at submission time |
| Constructor and description |
|---|
AwaitablePromiseFactory() |
AwaitablePromiseFactory(java.util.concurrent.Executor executor) |
| Type Params | Return Type | Name and description |
|---|---|---|
<T> |
protected Awaitable<java.util.List<java.lang.Object>> |
all(java.util.List<Promise<T>> promises)Combines the promises with Awaitable.all. |
<T> |
Promise<T> |
createPromise(java.lang.Class<T> returnType) |
|
Promise<java.lang.Object> |
createPromise() |
<T> |
Promise<T> |
createPromise(Closure<T>[] closures) |
<T> |
Promise<java.util.List<T>> |
createPromise(java.util.List<Closure<T>> closures, java.util.List<PromiseDecorator> decorators) |
<T> |
protected Promise<T> |
createPromiseInternal(Closure<T> callable)Submits an already decorated closure to the configured executor, or to Groovy's default async executor when none was supplied, and exposes the result as an Awaitable. |
<T> |
Promise<java.util.List<T>> |
onComplete(java.util.List<Promise<T>> promises, Closure<T> callable) |
<T> |
Promise<java.util.List<T>> |
onError(java.util.List<Promise<T>> promises, Closure<?> callable) |
<T> |
java.util.List<T> |
waitAll(java.util.List<Promise<T>> promises) |
<T> |
java.util.List<T> |
waitAll(java.util.List<Promise<T>> promises, long timeout, java.util.concurrent.TimeUnit units) |
| Methods inherited from class | Name |
|---|---|
class AbstractPromiseFactory |
addPromiseDecoratorLookupStrategy, applyDecorators, createBoundPromise, createPromise, createPromise, createPromise, createPromise, createPromise, createPromise, createPromiseInternal, waitAll |
The executor tasks are submitted to, or null to use Awaitable.getExecutor
at submission time
Combines the promises with Awaitable.all. Promises created by this factory, and any other Awaitable or java.util.concurrent.CompletionStage, are combined directly. Any other promise that is already done is read inline; a pending one is awaited on this factory's executor so that bridging work never lands on a pool the factory does not own.
Submits an already decorated closure to the configured executor, or to Groovy's default async executor when none was supplied, and exposes the result as an Awaitable.
callable - the decorated work to run