revision

How far this engine has come: moved by every call that can change it, acquire, admit, extend, shrink, complete, cancel, reconcileCapacity, apply, attach and detach, whatever the call returns, since a refused acquire may still move the wake memory. Never moved by a read (topology, snapshot, persist, previewPicks, previewApply, explain, entitlement, reconcileLeases), nor by a call that throws, which changes nothing, nor by a checked apply refused as ApplyOutcome.TreeChanged, which reads topology and stops. Costs one field read: compare it with the revision the last pass saw before copying anything.

Read it as you read the rest of the engine, under the caller's scheduling lock. It is not persisted: see LocalHeddleRevision for why a revision held across a restart still compares correctly.

Samples

val tree = twoLanes()
val heavy = tree.groupId("heavy")
val light = tree.groupId("light")
val queued = setOf(heavy, light)
val policy = LocalPolicy(defaultReservation = 3L)
val (heddle, _) = LocalHeddle.fromTopology(tree, policy, epoch = 0L)
heddle.reconcileCapacity(totalSlots = 2L)

// The last pass saw this. Asking who goes next changes nothing, so the next pass can skip.
val seen = heddle.revision
heddle.previewPicks(mapOf(heavy to 1, light to 1), queued, listOf(3L))
check(heddle.revision == seen)

// A lease moves it, so the next pass looks again.
check(heddle.acquire(queued, queued, startedAt = 0L) is AcquireOutcome.Acquired)
check(heddle.revision > seen)

// It is not persisted, but a restore runs under a higher epoch, so the restored engine's
// revision is above every one the old engine had: a pass that saw the old one sees a change.
val restarted = LocalHeddle.restore(heddle.persist(), policy, epoch = 1L)
check(restarted.revision > heddle.revision)