summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/package.scala.disabled
blob: 42b4bf954cdae4f63beff139e911023f40f792ed (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */



package scala




/** This package object contains primitives for parallel programming.
 */
package object concurrent {
  
  /** Performs a call which can potentially block execution.
   *  
   *  Example:
   *  {{{
   *    val lock = new ReentrantLock
   *    
   *    // ... do something ...
   *    
   *    blocking {
   *      if (!lock.hasLock) lock.lock()
   *    }
   *  }}}
   *  
   *  '''Note:''' calling methods that wait arbitrary amounts of time
   *  (e.g. for I/O operations or locks) may severely decrease performance
   *  or even result in deadlocks. This does not include waiting for
   *  results of futures.
   *
   *  @tparam T       the result type of the blocking operation
   *  @param body     the blocking operation
   *  @param runner   the runner used for parallel computations
   *  @return         the result of the potentially blocking operation
   */
  def blocking[T](body: =>T)(implicit runner: TaskRunner): T = {
    null.asInstanceOf[T]
  }
  
  /** Invokes a computation asynchronously. Does not wait for the computation
   *  to finish.
   *  
   *  @tparam U       the result type of the operation
   *  @param p        the computation to be invoked asynchronously
   *  @param runner   the runner used for parallel computations
   */
  def spawn[U](p: =>U)(implicit runner: TaskRunner): Unit = {
  }
  
  /** Starts 2 parallel computations and returns once they are completed.
   *  
   *  $invokingPar
   *  
   *  @tparam T1    the type of the result of 1st the parallel computation
   *  @tparam T2    the type of the result of 2nd the parallel computation
   *  @param b1     the 1st computation to be invoked in parallel
   *  @param b2     the 2nd computation to be invoked in parallel
   *  @param runner   the runner used for parallel computations
   *  @return       a tuple of results corresponding to parallel computations
   */
  def par[T1, T2](b1: =>T1)(b2: =>T2)(implicit runner: TaskRunner): (T1, T2) = {
    null
  }
  
  /** Starts 3 parallel computations and returns once they are completed.
   *  
   *  $invokingPar
   *
   *  @tparam T1    the type of the result of 1st the parallel computation
   *  @tparam T2    the type of the result of 2nd the parallel computation
   *  @tparam T3    the type of the result of 3rd the parallel computation
   *  @param b1     the 1st computation to be invoked in parallel
   *  @param b2     the 2nd computation to be invoked in parallel
   *  @param b3     the 3rd computation to be invoked in parallel
   *  @param runner   the runner used for parallel computations
   *  @return       a tuple of results corresponding to parallel computations
   */
  def par[T1, T2, T3](b1: =>T1)(b2: =>T2)(b3: =>T3)(implicit runner: TaskRunner): (T1, T2, T3) = {
    null
  }
  
  /** Starts 4 parallel computations and returns once they are completed.
   *  
   *  $invokingPar
   *
   *  @tparam T1    the type of the result of 1st the parallel computation
   *  @tparam T2    the type of the result of 2nd the parallel computation
   *  @tparam T3    the type of the result of 3rd the parallel computation
   *  @tparam T4    the type of the result of 4th the parallel computation
   *  @param b1     the 1st computation to be invoked in parallel
   *  @param b2     the 2nd computation to be invoked in parallel
   *  @param b3     the 3rd computation to be invoked in parallel
   *  @param b4     the 4th computation to be invoked in parallel
   *  @param runner   the runner used for parallel computations
   *  @return       a tuple of results corresponding to parallel computations
   */
  def par[T1, T2, T3, T4](b1: =>T1)(b2: =>T2)(b3: =>T3)(b4: =>T4)(implicit runner: TaskRunner): (T1, T2, T3, T4) = {
    null
  }
  
}