summaryrefslogblamecommitdiff
path: root/sources/scala/concurrent/SyncVar.scala
blob: ead0d1635c1907599005490a5e9b0bea7884548b (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                         
                               
                                         





                                
                                               



                            
                      


   
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;
  }
}