maxConcurrent

abstract val maxConcurrent: Long?

The most leases that may be open beneath this child at once, or null for no ceiling. 0 pauses it: nothing beneath it is picked. Never negative. A LocalHeddle running this topology picks nothing beneath a child whose open leases have reached it, and counts the child idle at its parent until they drop below; it refuses no charge for work already running there. LocalHeddle.explain tells a leaf waiting on it WaitExplanation.AtCeiling.

Samples

val tree = draft("pool") {
    lane("deploys", Weight.of(3), maxConcurrent = 1)
    lane("builds")
}
val deploys = tree.groupId("deploys")
val builds = tree.groupId("builds")
val (heddle, booted) = LocalHeddle.fromTopology(tree, LocalPolicy(defaultReservation = 1L), epoch = 0L)
check(booted.refusals.isEmpty())
heddle.reconcileCapacity(totalSlots = 4L)
val queued = setOf(deploys, builds)

val deploy = (heddle.acquire(queued, queued, startedAt = 0L) as AcquireOutcome.Acquired).lease
check(deploy.leaf == deploys)
// Deploys weigh three times as much, but one is already running, its ceiling.
check(heddle.explain(deploys, waiting = queued, eligible = queued) == WaitExplanation.AtCeiling(deploys, limit = 1L))
check(heddle.entitlement(builds, waiting = queued, totalSlots = 4L) == Rational.of(4L))
check((heddle.acquire(queued, queued, startedAt = 1L) as AcquireOutcome.Acquired).lease.leaf == builds)

heddle.complete(deploy.id, actualCost = 1L, waiting = queued)
// Deploys compete again, a third of a build ahead, as they were when they reached the ceiling.
val back = heddle.explain(deploys, waiting = queued, eligible = queued)
check(back is WaitExplanation.BehindAtLevel && back.leafSideVirtualService == Rational.of(4L, 3L) && back.front == Rational.of(5L, 4L))
check(heddle.explain(builds, waiting = queued, eligible = queued) == WaitExplanation.WouldBePickedNext)