summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/package.scala
blob: e8921ef5315be5d7d20b1caf83e766bceb162f9f (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
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

package scala

import scala.util.{ Try, Success, Failure }
import scala.concurrent.util.Duration

/** This package object contains primitives for concurrent and parallel programming.
 */
package object concurrent extends scala.concurrent.ConcurrentPackageObject {
  type ExecutionException =    java.util.concurrent.ExecutionException
  type CancellationException = java.util.concurrent.CancellationException
  type TimeoutException =      java.util.concurrent.TimeoutException
}

package concurrent {
  
  sealed trait CanAwait
  
  object Await {
    private[concurrent] implicit val canAwaitEvidence = new CanAwait {}
    
    def ready[T](awaitable: Awaitable[T], atMost: Duration): awaitable.type = {
      blocking(awaitable, atMost)
      awaitable
    }
    
    def result[T](awaitable: Awaitable[T], atMost: Duration): T = {
      blocking(awaitable, atMost)
    }
    
  }

  final class DurationOps private[concurrent] (x: Int) {
    // TODO ADD OTHERS
    def ns = util.Duration.fromNanos(0)
  }
}