Files
sbt/util/env/LazyVar.scala
T
Mark Harrah d0fa1eb461 * move Environment classes to util/env module
* move TrapExit, SelectMainClass to run module
* rearrange some compilation-related code
* Jetty-related code moved to web module
2010-07-14 19:24:50 -04:00

22 lines
432 B
Scala

/* sbt -- Simple Build Tool
* Copyright 2008 Mark Harrah
*/
package sbt
private final class LazyVar[T](initialValue: => T) extends NotNull
{
private[this] var value: Option[T] = None
def apply() =
synchronized
{
value match
{
case Some(v) => v
case None =>
val newValue = initialValue
value = Some(newValue)
newValue
}
}
def update(newValue: T) = synchronized { value = Some(newValue) }
}