Documentation
¶
Overview ¶
Package budget counts the work and the size of a compile against their limits. A Limit says how far a count may go, or that nothing bounds it, and a Budget counts what is spent against one (GitHub #785).
Every count the compile holds to a limit counts through it, so "unbounded" has one spelling, the zero Limit, and no sum passes math.MaxInt. A depth, a chain's hops or a constant compared beside the one loop it bounds needs neither and stays beside its check. What crossing a limit does stays with the site that counts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Budget ¶
type Budget struct {
// contains filtered or unexported fields
}
Budget counts what is spent against a Limit. The zero Budget is unbounded and has spent nothing. It is a value: a copy counts on its own.
func (*Budget) Exhaust ¶
func (b *Budget) Exhaust()
Exhaust spends all that is left and one more, so nothing fits, an unbounded budget included: for a count that has found it would never end.
func (*Budget) Exhausted ¶
Exhausted reports whether the budget is past its limit, was exhausted, or was charged what no count is.
func (*Budget) Remaining ¶
Remaining returns the Limit on what may yet be spent: what is left of a bounded limit, nothing once exhausted, and no bound under an unbounded one.
type Limit ¶
type Limit struct {
// contains filtered or unexported fields
}
Limit is how far a count may go: at most some number, or without bound. The zero Limit is unbounded, so an options field a caller leaves unset bounds nothing, as every internal options type the compiler projects its public budgets onto has it.
func AtMost ¶
AtMost returns the Limit a count crosses once it passes n. A negative n is taken as zero, which admits nothing: the safe direction, where the public spelling would read a negative budget as none at all.
func FromOption ¶
FromOption returns the Limit a budget set as openapi.Limits spells one: value itself, def where value is zero, and unbounded where it is negative. It is the one place that spelling is read.
func (Limit) Cap ¶
Cap returns l as the bound of a loop: its most, or math.MaxInt where l is unbounded, which no count of what memory holds reaches.