summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/Awaitable.scala
blob: 3bd7617bce88063d621049a1833ae5f869bf9e2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

package scala.concurrent



import scala.concurrent.duration.Duration



trait Awaitable[+T] {
  /**
   * Await the "resolved" state of this Awaitable.
   * This method should not be called directly.
   *
   * @param atMost
   *        maximum wait time, which may be negative (no waiting is done),
   *        [[Duration.Inf]] for unbounded waiting, or a finite positive
   *        duration
   * @return the Awaitable itself
   * @throws InterruptedException     if the wait call was interrupted
   * @throws TimeoutException         if after waiting for the specified time this Awaitable is still not ready
   * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]]
   */
  @throws(classOf[TimeoutException])
  @throws(classOf[InterruptedException])
  def ready(atMost: Duration)(implicit permit: CanAwait): this.type
  
  /**
   * Await and return the result of this Awaitable, which is either of type T or a thrown exception (any Throwable).
   * This method should not be called directly.
   *
   * @param atMost
   *        maximum wait time, which may be negative (no waiting is done),
   *        [[Duration.Inf]] for unbounded waiting, or a finite positive
   *        duration
   * @return the value if the Awaitable was successful within the specific maximum wait time
   * @throws InterruptedException     if the wait call was interrupted
   * @throws TimeoutException         if after waiting for the specified time this Awaitable is still not ready
   * @throws IllegalArgumentException if `atMost` is [[Duration.Undefined]]
   */
  @throws(classOf[Exception])
  def result(atMost: Duration)(implicit permit: CanAwait): T
}