Record write-once lazy builds against repeated reads and report the cache state.

Lazy Value Coordination Report

LazyValueCoordinationReport.scala
object Main {
  def main(args: Array[String]): Unit = {
    val reads = 
    var builds = 0
    lazy val cached = {
      builds = builds + 1
      7
    }
    var served = 0

    for (i <- 0 until reads) {
      if (cached > 0) {
        served = served + 1
      }
    }

    var status = "set"
    if (builds == 0) {
      status = "unset"
    }
    if (served > 1) {
      status = "locked"
    }

    println("reads=" + reads + " served=" + served + " builds=" + builds + " " + status)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val reads = 
    var builds = 0
    lazy val cached = {
      builds = builds + 1
      7
    }
    var served = 0

    for (i <- 0 until reads) {
      if (cached > 0) {
        served = served + 1
      }
    }

    var status = "set"
    if (builds == 0) {
      status = "unset"
    }
    if (served > 1) {
      status = "locked"
    }

    println("reads=" + reads + " served=" + served + " builds=" + builds + " " + status)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val reads = 
    var builds = 0
    lazy val cached = {
      builds = builds + 1
      7
    }
    var served = 0

    for (i <- 0 until reads) {
      if (cached > 0) {
        served = served + 1
      }
    }

    var status = "set"
    if (builds == 0) {
      status = "unset"
    }
    if (served > 1) {
      status = "locked"
    }

    println("reads=" + reads + " served=" + served + " builds=" + builds + " " + status)
  }
}
write-once lazy A coordination report can record how a write-once value is shared. A Scala `lazy val` runs its initializer the first time the value is read and caches the result, so repeated reads reuse the single build. With no reads the slot is unset, with one read it is set, and with repeated reads it is locked to the one cached build. The status line summarizes whether the slot stayed unset, set, or locked after the recorded reads, while the build counter confirms the initializer ran at most once.