Await the "completed" state of an Awaitable.
Await the "completed" state of an Awaitable.
Although this method is blocking, the internal use of blocking ensures that the underlying ExecutionContext is prepared to properly manage the blocking.
the Awaitable to be awaited
maximum wait time, which may be negative (no waiting is done), Duration.Inf for unbounded waiting, or a finite positive duration
the awaitable
IllegalArgumentException if atMost is Duration.Undefined
InterruptedException if the current thread is interrupted while waiting
TimeoutException if after waiting for the specified time this Awaitable is still not ready
Await and return the result (of type T) of an Awaitable.
Await and return the result (of type T) of an Awaitable.
Although this method is blocking, the internal use of blocking ensures that the underlying ExecutionContext to properly detect blocking and ensure that there are no deadlocks.
the Awaitable to be awaited
maximum wait time, which may be negative (no waiting is done), Duration.Inf for unbounded waiting, or a finite positive duration
the result value if awaitable is completed within the specific maximum wait time
IllegalArgumentException if atMost is Duration.Undefined
InterruptedException if the current thread is interrupted while waiting
TimeoutException if after waiting for the specified time awaitable is still not ready
Awaitis what is used to ensure proper handling of blocking forAwaitableinstances.While occasionally useful, e.g. for testing, it is recommended that you avoid Await when possible in favor of callbacks and combinators like onComplete and use in for comprehensions. Await will block the thread on which it runs, and could cause performance and deadlock issues.