summaryrefslogtreecommitdiff
path: root/sources/scala/concurrent/SyncVar.scala
blob: ead0d1635c1907599005490a5e9b0bea7884548b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package scala.concurrent;

class SyncVar[a] with Monitor {
  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;
  }
}