ZoneRequest

class ZoneRequest : ZoneClosureIfc(source)

A request for guide-path space: what was asked for, before it has been given.

The middle term of a trio that mirrors the resource layer exactly, which is the analogy this whole construct is built on. A Zone is the persistent thing with its own occupancy, as a Resource is; a ZoneRequest is what somebody asked for and is waiting on, as an Entity.Request is; and a ZoneAllocation is the transient record of the grant, as an Allocation is.

A request exists because a grant is not instant. Between asking and holding, the zone drains: whatever vehicle is crossing it finishes crossing, whatever is present in it leaves, and only then can the zone be given. Nothing is evicted. So there is a state here that the resource layer has no equivalent of -- asked for, promised, not yet held -- and this is the object that has it.

Requests are made by asking the GuidedPathSpace, never by construction: the space has to stay in charge of its own exclusivity, which is the invariant the whole subsystem rests on.

A set is taken all at once or not at all. Taking the zones one by one as they drain is what creates the trap described on ZoneClosureIfc; waiting until every zone has drained and then claiming them together prevents that trap rather than leaving it to be detected. It does not make the holder incapable of lying on a circular wait: sequence and the escape rule on ZoneClosureIfc exist because two closures over abutting regions can wait on each other through their reservations alone, whatever either one holds. The cost of the rule is that a closure over a busy region begins later, and that delay is reported rather than hidden: the space keeps it as a response of its own.

Parameters

holder

who asked

zones

what was asked for, one or more

requestedAt

when it was asked for

sequence

where this request falls in the strict order of every request the guide path has taken, which is what the escape rule on ZoneClosureIfc is ordered by

holdFor

how long to hold the space once the hold begins, or NaN to hold it until the holder gives it back. Measured from the instant the hold begins, never from the request, or a two-minute drain would silently eat two minutes out of a twenty-minute closure.

action

what to tell when the hold begins and when it ends

Properties

Link copied to clipboard

The grant, once the zones have drained and been taken, or null while any is still draining.

Link copied to clipboard
open override val holder: ZoneHolderIfc
Link copied to clipboard
Link copied to clipboard

True while the zone is still draining, or once the request was given up unsatisfied.

Link copied to clipboard
open override val isDrained: Boolean

True when every zone asked for has drained and could now be taken together.

Link copied to clipboard

True once the zone has been taken.

Link copied to clipboard

True when the space is to be given back on a clock rather than by hand.

Link copied to clipboard

True while the request is neither granted nor given up: asked for and still draining.

Link copied to clipboard
Link copied to clipboard
open override val sequence: Long
Link copied to clipboard
val zone: Zone

The single zone asked for, when exactly one was.

Link copied to clipboard
open override val zones: List<Zone>

Functions

Link copied to clipboard
open override fun admits(claimant: ZoneHolderIfc): Boolean

Three things may take a zone this closure has reserved, and ZoneClosureIfc says why each is needed: the holder it is promised to, which is how the grant is taken up; a vehicle already inside this region, which is how that vehicle leaves; and a vehicle escaping a region reserved before this one, which is what stops two closures trapping each other.

Link copied to clipboard
open override fun toString(): String