| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Server.Admission.Budget
Description
The arithmetic of the metadata memory budget: what a byte count costs, how many steps cover a shortfall, and which request the meter lets move. Ecluse.Core.Server.Admission.Meter applies these decisions inside its transactions.
Synopsis
- scaleCharge :: Int -> Int -> Int
- roundUpToStep :: Int -> Int -> Int
- data MeterView = MeterView {}
- data EntryGate
- entryDecision :: MeterView -> Int -> Int -> Int -> EntryGate
- entryReady :: MeterView -> Int -> Bool
- data GrowthGate
- growthDecision :: MeterView -> IntSet -> Int -> GrowthGate
Charges
scaleCharge :: Int -> Int -> Int Source #
The charge for a byte count, rounded up, so a non-empty read never costs nothing.
roundUpToStep :: Int -> Int -> Int Source #
The smallest whole number of steps that covers a shortfall, in bytes.
Decisions
What a meter transaction reads before it decides.
Constructors
| MeterView | |
The gate's answer to a new request.
Constructors
| EntryAdmit | The entry step fits now. |
| EntryQueue | Wait for the step, up to the admission wait. |
| EntryRefuse | The waiting room is full: shed at once. |
entryDecision :: MeterView -> Int -> Int -> Int -> EntryGate Source #
New work takes its entry step only when it fits, nobody queued before it, and no started read is paused. A paused read always has the prior claim on freed memory.
entryReady :: MeterView -> Int -> Bool Source #
Whether a queued request may take its entry step now.
data GrowthGate Source #
The answer to a started request that needs more bytes.
Constructors
| GrowWithin | The step fits within the budget. |
| GrowOnToken | The step does not fit, but it serves the ticket that holds the overdraw token. |
| GrowTakeToken | The step does not fit, the token is free, and this charge serves the oldest paused ticket. |
| GrowWait | Pause until memory frees. |
Instances
| Show GrowthGate Source # | |
Defined in Ecluse.Core.Server.Admission.Budget Methods showsPrec :: Int -> GrowthGate -> ShowS # show :: GrowthGate -> String # showList :: [GrowthGate] -> ShowS # | |
| Eq GrowthGate Source # | |
Defined in Ecluse.Core.Server.Admission.Budget | |
growthDecision :: MeterView -> IntSet -> Int -> GrowthGate Source #
A step that fits proceeds. Past the budget, only work serving the token holder moves, or with a free
token, work serving the oldest paused ticket. served: the charging ticket and those waiting on it.