Package-level declarations

Types

Link copied to clipboard
class FairSharePool(engine: LocalHeddle, slots: Int, timeSource: TimeSource.WithComparableMarks, costUnit: Duration, clockStart: Long = 0)

Wait your turn for a slot. A build farm has four agents and two lanes, web and mobile; a program handing them out wants to say "run this in web's lane when it is web's turn" and have that one line wait. A FairSharePool holds a LocalHeddle, which knows whose turn it is, and a count of slots. withSlot suspends until fair share grants the caller's leaf a slot, runs the work, and charges the lane the time the work took, however it ends. acquire is the same wait on its own: the caller hands the slot back with complete or cancel.

Link copied to clipboard
data class PoolView(val queues: Map<GroupId, List<Long>>, val open: Int, val slots: Int)

What a FairSharePool holds at one moment: who is queued for which lane, how many slots are in use, and how many there are. A status page that shows "who goes next" reads it rather than keeping its own count beside the pool's, which would race it.

Link copied to clipboard
sealed interface SlotOutcome

What FairSharePool.acquire answered: a slot, or the reason none can be granted to that leaf as the tree stands now.

Link copied to clipboard

What FairSharePool.withSlot throws where FairSharePool.acquire would answer SlotOutcome.Refused: no lease can be granted to the leaf as the tree stands now, so the block never runs.