blob: 0e1b9fd38c41b0c86d955ba1d2e84dd8b1c6a8f3 (
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
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-04, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
** $Id$
\* */
package scala.concurrent;
class SyncVar[a] {
private var isDefined: Boolean = false;
private var value: a = _;
def get = synchronized {
if (!isDefined) wait();
value
}
def set(x: a) = synchronized {
value = x;
isDefined = true;
notifyAll()
}
def isSet: Boolean = synchronized {
isDefined;
}
def unset = synchronized {
isDefined = false
}
}
|