Await

object Await

Await is what is used to ensure proper handling of blocking for Awaitable instances.

While occasionally useful, e.g. for testing, it is recommended that you avoid Await whenever possible— instead favoring combinators and/or callbacks. Await's result and ready methods will block the calling thread's execution until they return, which will cause performance degradation, and possibly, deadlock issues.

Source:
package.scala
class Object
trait Matchable
class Any
Await.type

Value members

Concrete methods

@throws(scala.Predef.classOf[scala.concurrent.TimeoutException]) @throws(scala.Predef.classOf[scala.InterruptedException])
final def ready[T](awaitable: Awaitable[T], atMost: Duration): awaitable.type

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 given an opportunity to properly manage the blocking.

WARNING: It is strongly discouraged to supply lengthy timeouts since the progress of the calling thread will be suspended—blocked—until either the Awaitable becomes ready or the timeout expires.

Value parameters:
atMost

maximum wait time, which may be negative (no waiting is done), Duration.Inf for unbounded waiting, or a finite positive duration

awaitable

the Awaitable to be awaited

Returns:

the awaitable

Throws:
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

Source:
package.scala
@throws(scala.Predef.classOf[scala.concurrent.TimeoutException]) @throws(scala.Predef.classOf[scala.InterruptedException])
final def result[T](awaitable: Awaitable[T], atMost: Duration): T

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 is given an opportunity to properly manage the blocking.

WARNING: It is strongly discouraged to supply lengthy timeouts since the progress of the calling thread will be suspended—blocked—until either the Awaitable has a result or the timeout expires.

Value parameters:
atMost

maximum wait time, which may be negative (no waiting is done), Duration.Inf for unbounded waiting, or a finite positive duration

awaitable

the Awaitable to be awaited

Returns:

the result value if awaitable is completed within the specific maximum wait time

Throws:
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

Source:
package.scala