blob: ec3fd281e271e3167b67a20bdbd8baa85d5da71f (
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 =
isDefined;
def unset = synchronized {
isDefined = false
}
}
|