capacityledger

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package capacityledger accounts for retained capacity without choosing admission, eviction, or scheduling policy. A domain owner serializes a ledger tree and all its holds with the same lock it uses for those decisions. This keeps allocation, cache pinning, and reclamation atomic without adding another lock to the hot path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hold

type Hold struct {
	// contains filtered or unexported fields
}

Hold is a copy-safe claim on already charged capacity. Copies share ownership; Transfer invalidates every old copy without briefly making capacity available. All methods follow the ledger owner's serialization contract.

func (Hold) Grow

func (h Hold) Grow(units uint64) bool

Grow meters a logical operation cumulatively, so a directory scan or a cache need not allocate an ownership record for every increment.

func (Hold) Release

func (h Hold) Release() bool

func (Hold) Shrink

func (h Hold) Shrink(units uint64) bool

func (Hold) Split

func (h Hold) Split(units uint64) (Hold, bool)

Split partitions existing ownership without another admission or a release / reacquire gap. Splitting the whole hold consumes the source capability.

func (Hold) Transfer

func (h Hold) Transfer() (Hold, bool)

func (Hold) Units

func (h Hold) Units() uint64

type Ledger

type Ledger struct {
	// contains filtered or unexported fields
}

Ledger must not be copied after first use. Related ledgers use one owner lock.

func New

func New(limit uint64) *Ledger

func (*Ledger) Available

func (l *Ledger) Available() uint64

Available includes every ancestor ceiling and admission boundary.

func (*Ledger) Child

func (l *Ledger) Child(limit uint64) *Ledger

func (*Ledger) Close

func (l *Ledger) Close() error

func (*Ledger) Limit

func (l *Ledger) Limit() uint64

func (*Ledger) Owns

func (l *Ledger) Owns(hold Hold) bool

func (*Ledger) Reserve

func (l *Ledger) Reserve(units uint64) (Hold, bool)

func (*Ledger) Snapshot

func (l *Ledger) Snapshot() Snapshot

type Snapshot

type Snapshot struct {
	Limit  uint64
	Used   uint64
	Holds  uint64
	Closed bool
}

type UnreleasedError

type UnreleasedError struct {
	Used  uint64
	Holds uint64
}

UnreleasedError is a snapshot, not a revocation of live ownership. Late cleanup can still release its holds after admission has closed.

func (*UnreleasedError) Error

func (e *UnreleasedError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL