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

Explicit, thread-safe metadata recorder. Disabled by default; no clocks or I/O. enable/disable/snapshot are control-plane operations outside measure/layout/paint. Record admission tries the mutex once; it never waits, allocates, or calls user code. The recorder must outlive every DiagnosticScope borrowing it. A scheduler can share ownership. More...

#include <diagnostics.hpp>

Public Member Functions

 Diagnostics ()=default
 Construct a disabled recorder without allocating ring storage.
 Diagnostics (const Diagnostics &)=delete
Diagnostics & operator= (const Diagnostics &)=delete
std::expected< void, DiagnosticError > enable (DiagnosticOptions options={})
 Start a fresh recording interval; retain monotonic identities across intervals.
void disable () noexcept
 Stop admission and preserve retained evidence for export.
bool enabled () const noexcept
 Fast recording gate; safe on any thread.
std::uint64_t nextIdentity () noexcept
 Issue a never-reused identity only while enabled.
DiagnosticContext beginInput (DiagnosticInput input) noexcept
 Record the input boundary before publishing to the scheduler.
DiagnosticContext current () const noexcept
 Obtain this thread's explicitly installed context for this recorder.
void record (DiagnosticRecord record) noexcept
 Attempt one bounded append; disabled calls return before touching counters.
void note (DiagnosticEvent event, DiagnosticReason reason=DiagnosticReason::NONE, DiagnosticNodeId node={}) noexcept
 Record a common synchronous stage using the current context.
DiagnosticSnapshot snapshot () const
 Snapshot outside frame hooks; may allocate and throw std::bad_alloc.

Friends

class DiagnosticScope

Detailed Description

Explicit, thread-safe metadata recorder. Disabled by default; no clocks or I/O. enable/disable/snapshot are control-plane operations outside measure/layout/paint. Record admission tries the mutex once; it never waits, allocates, or calls user code. The recorder must outlive every DiagnosticScope borrowing it. A scheduler can share ownership.

Member Function Documentation

◆ beginInput()

DiagnosticContext portals::Diagnostics::beginInput ( DiagnosticInput input)
noexcept

Record the input boundary before publishing to the scheduler.

Parameters
inputEnumerated input category; no original payload is inspected.
Returns
Token to install with DiagnosticScope and propagate through publication.

◆ current()

DiagnosticContext portals::Diagnostics::current ( ) const
noexcept

Obtain this thread's explicitly installed context for this recorder.

Returns
Current token, or an empty token when disabled/unscoped.

◆ enable()

std::expected< void, DiagnosticError > portals::Diagnostics::enable ( DiagnosticOptions options = {})

Start a fresh recording interval; retain monotonic identities across intervals.

Parameters
optionsPositive bounded ring capacity, reserved before recording starts.
Returns
Success, INVALID_ARGUMENT, or NO_MEMORY. Exhausted recorders cannot restart.

◆ enabled()

bool portals::Diagnostics::enabled ( ) const
noexcept

Fast recording gate; safe on any thread.

Returns
True only while record admission is enabled.

◆ nextIdentity()

std::uint64_t portals::Diagnostics::nextIdentity ( )
noexcept

Issue a never-reused identity only while enabled.

Returns
New identity, or zero when disabled/exhausted.

◆ note()

void portals::Diagnostics::note ( DiagnosticEvent event,
DiagnosticReason reason = DiagnosticReason::NONE,
DiagnosticNodeId node = {} )
noexcept

Record a common synchronous stage using the current context.

Parameters
eventStage actually reached.
reasonKnown result, or OUTCOME_UNKNOWN for unobserved user effects.
nodeGeneration-aware target identity; empty when unavailable.

◆ record()

void portals::Diagnostics::record ( DiagnosticRecord record)
noexcept

Attempt one bounded append; disabled calls return before touching counters.

Parameters
recordFixed-size metadata; sequence is assigned internally.

◆ snapshot()

DiagnosticSnapshot portals::Diagnostics::snapshot ( ) const

Snapshot outside frame hooks; may allocate and throw std::bad_alloc.

Returns
Bounded owning evidence; missing events must never be interpreted as absence of work.

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