Class Awaitable<T>
- Type Parameters:
T
- type of the awaitable result
- Direct Known Subclasses:
AnyAwaitable
,Awakeable
Awaitable
allows to await an asynchronous result. Once await()
is called, the
execution stops until the asynchronous result is available.
The result can be either a success or a failure. In case of a failure, await()
will
throw a TerminalException
.
NOTE: This interface MUST NOT be accessed concurrently since it can lead to different orderings of user actions, corrupting the execution of the invocation.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate anAwaitable
that awaits all the given awaitables.Create anAwaitable
that awaits all the given awaitables.static AnyAwaitable
Create anAwaitable
that awaits any of the given awaitables.static AnyAwaitable
Create anAwaitable
that awaits any of the given awaitables.final T
await()
Wait for the current awaitable to complete.final T
Same asawait()
, but throws aTimeoutException
if thisAwaitable
doesn't complete before the providedtimeout
.protected abstract Deferred
<?> deferred()
final <U> Awaitable
<U> map
(ThrowingFunction<T, U> mapper) Map the result of thisAwaitable
.
-
Field Details
-
syscalls
-
-
Method Details
-
deferred
-
awaitResult
-
await
Wait for the current awaitable to complete. Executing this method may trigger the suspension of the function.NOTE: You should never wrap this invocation in a try-catch catching
RuntimeException
, as it will catchAbortedExecutionException
as well.- Throws:
TerminalException
- if the awaitable is ready and contains a failure
-
await
Same asawait()
, but throws aTimeoutException
if thisAwaitable
doesn't complete before the providedtimeout
.- Throws:
TerminalException
TimeoutException
-
map
Map the result of thisAwaitable
. -
any
Create anAwaitable
that awaits any of the given awaitables.The behavior is the same as
CompletableFuture.anyOf(CompletableFuture[])
. -
any
Create anAwaitable
that awaits any of the given awaitables.An empty list is not supported and will throw
IllegalArgumentException
.The behavior is the same as
CompletableFuture.anyOf(CompletableFuture[])
. -
all
Create anAwaitable
that awaits all the given awaitables.The behavior is the same as
CompletableFuture.allOf(CompletableFuture[])
. -
all
Create anAwaitable
that awaits all the given awaitables.An empty list is not supported and will throw
IllegalArgumentException
.The behavior is the same as
CompletableFuture.allOf(CompletableFuture[])
.
-