Admit readers against a fixed permit pool and turn the remaining permits into an admit, hold, or shed remediation action.

Permit Pool Remediation Report

PermitPoolRemediationReport.scala
object Main {
  def main(args: Array[String]): Unit = {
    val readers = 
    val capacity = 3
    var admitted = readers
    if (admitted > capacity) {
      admitted = capacity
    }
    val remaining = capacity - admitted

    var action = "admit"
    if (remaining == 1) {
      action = "hold"
    }
    if (remaining == 0) {
      action = "shed"
    }

    println("readers=" + readers + " admitted=" + admitted + " remaining=" + remaining + " " + action)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val readers = 
    val capacity = 3
    var admitted = readers
    if (admitted > capacity) {
      admitted = capacity
    }
    val remaining = capacity - admitted

    var action = "admit"
    if (remaining == 1) {
      action = "hold"
    }
    if (remaining == 0) {
      action = "shed"
    }

    println("readers=" + readers + " admitted=" + admitted + " remaining=" + remaining + " " + action)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val readers = 
    val capacity = 3
    var admitted = readers
    if (admitted > capacity) {
      admitted = capacity
    }
    val remaining = capacity - admitted

    var action = "admit"
    if (remaining == 1) {
      action = "hold"
    }
    if (remaining == 0) {
      action = "shed"
    }

    println("readers=" + readers + " admitted=" + admitted + " remaining=" + remaining + " " + action)
  }
}
remaining capacity The permit pool is modeled with a scalar counter, so the remaining permits stay deterministic and free of atomic identity while driving the remediation action.