Package org.signal.libsignal.internal
Class AsyncKt
-
- All Implemented Interfaces:
public final class AsyncKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> Tawait(CompletableFuture<T> $self)Awaits for completion of this CompletableFuture without blocking a thread. final static <T extends Any> CompletableFuture<Result<T>>toResultFuture(CompletableFuture<T> $self)Converts a CompletableFuture<T>to aCompletableFuture<Result<T>>.-
-
Method Detail
-
await
final static <T extends Any> T await(CompletableFuture<T> $self)
Awaits for completion of this CompletableFuture without blocking a thread.
This suspending function is cancellable. If the coroutine is cancelled while this function is suspended, the future will be cancelled as well.
- Returns:
The result value of the CompletableFuture
-
toResultFuture
final static <T extends Any> CompletableFuture<Result<T>> toResultFuture(CompletableFuture<T> $self)
Converts a
CompletableFuture<T>to aCompletableFuture<Result<T>>.This helper function wraps the result of a CompletableFuture in a Result, catching any exceptions and converting them to
Result.failure().Uses libsignal's chaining mechanism to ensure proper bidirectional cancellation propagation for long async operations, like network requests.
- Returns:
A new CompletableFuture that completes with
Result.success(value)orResult.failure(exception)
-
-
-
-