Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::SourceCapacityObserver Class Reference

Move-only worker-safe capacity observation; destruction unregisters without waiting. More...

#include <source_budget.hpp>

Public Member Functions

 SourceCapacityObserver ()=default
 Empty observer; admission returns CLOSED.
 ~SourceCapacityObserver ()
 Unregister without allocation or callbacks into UI.
 SourceCapacityObserver (SourceCapacityObserver &&other) noexcept
SourceCapacityObserver & operator= (SourceCapacityObserver &&other) noexcept
 SourceCapacityObserver (const SourceCapacityObserver &)=delete
std::expected< SourceCredit, SourceError > reserve (SourceBudgetUsage amount, SourceBudgetUsage peak)
std::expected< void, SourceError > arm (SourceBudgetUsage peak)
bool takeReady () noexcept
void disarm () noexcept
 Drop pending admission priority; no UI callback or worker join occurs.

Friends

class SourceBudget

Detailed Description

Move-only worker-safe capacity observation; destruction unregisters without waiting.

Constructor & Destructor Documentation

◆ SourceCapacityObserver()

portals::SourceCapacityObserver::SourceCapacityObserver ( SourceCapacityObserver && other)
noexcept
Parameters
otherRegistration to transfer and leave empty.

Member Function Documentation

◆ arm()

std::expected< void, SourceError > portals::SourceCapacityObserver::arm ( SourceBudgetUsage peak)
Parameters
peakComplete next-turn demand.
Returns
Armed one-shot notification or a typed permanent limit. Capacity is rechecked atomically; a release before arming cannot be lost.

◆ operator=()

SourceCapacityObserver & portals::SourceCapacityObserver::operator= ( SourceCapacityObserver && other)
noexcept
Parameters
otherRegistration replacing this one.
Returns
This observer after unregistering the old one.

◆ reserve()

std::expected< SourceCredit, SourceError > portals::SourceCapacityObserver::reserve ( SourceBudgetUsage amount,
SourceBudgetUsage peak )
Parameters
amountActual reservation.
peakComplete simultaneous demand, including amount.
Returns
Charged credit after an atomic peak check, WOULD_BLOCK, or PAGE_TOO_LARGE for impossible demand.

◆ takeReady()

bool portals::SourceCapacityObserver::takeReady ( )
noexcept
Returns
Whether an armed notification granted admission priority, consuming only its ready flag.

The documentation for this class was generated from the following file: