StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Clock::Sample Class Referencefinal

One independently timed interval contributing to a shared Clock. More...

#include <StormByte/telemetry.hxx>

Public Member Functions

 Sample () noexcept=default
 Construct an empty, inactive sample token.
 Sample (const Sample &other)=delete
 Copy construction is disabled for single-owner sample tokens.
Sample & operator= (const Sample &other)=delete
 Copy assignment is disabled for single-owner sample tokens.
 Sample (Sample &&other) noexcept
 Transfer responsibility for recording the active sample.
Sample & operator= (Sample &&other) noexcept
 Record this sample and take responsibility for another.
 ~Sample () noexcept
 Record this sample if it is still active.
bool Active () const noexcept
 Whether this token owns a measurement that will be recorded.
STORMBYTE_FORCE_INLINE std::chrono::microseconds Stop () noexcept
 Complete and record this sample once.

Friends

class Clock

Detailed Description

One independently timed interval contributing to a shared Clock.

Each sample owns its start time. Samples from the same Clock may overlap or nest on any threads without replacing one another. Stop is idempotent; an active sample is recorded on explicit Stop or destruction. A Sample is a single-owner token and must not be accessed concurrently by multiple threads. It may be moved to the thread that will stop it.

Constructor & Destructor Documentation

◆ Sample() [1/3]

StormByte::Clock::Sample::Sample ( )
defaultnoexcept

Construct an empty, inactive sample token.

◆ Sample() [2/3]

StormByte::Clock::Sample::Sample ( const Sample & other)
delete

Copy construction is disabled for single-owner sample tokens.

Parameters
otherSource sample; it remains owned by its current token.

◆ Sample() [3/3]

StormByte::Clock::Sample::Sample ( Sample && other)
noexcept

Transfer responsibility for recording the active sample.

Parameters
otherSource sample; it becomes inactive.

◆ ~Sample()

StormByte::Clock::Sample::~Sample ( )
noexcept

Record this sample if it is still active.

Member Function Documentation

◆ Active()

bool StormByte::Clock::Sample::Active ( ) const
noexcept

Whether this token owns a measurement that will be recorded.

Returns
False for an empty token, after Stop, or when best-effort creation failed.

◆ operator=() [1/2]

Sample & StormByte::Clock::Sample::operator= ( const Sample & other)
delete

Copy assignment is disabled for single-owner sample tokens.

Parameters
otherSource sample.
Returns
No value; this operation is deleted.

◆ operator=() [2/2]

Sample & StormByte::Clock::Sample::operator= ( Sample && other)
noexcept

Record this sample and take responsibility for another.

Parameters
otherSource sample; it becomes inactive.
Returns
This sample token.

◆ Stop()

STORMBYTE_FORCE_INLINE std::chrono::microseconds StormByte::Clock::Sample::Stop ( )
inlinenoexcept

Complete and record this sample once.

Returns
This sample's elapsed microseconds; repeated calls return the same value. Built in the caller. The DLL returns the tick count.

◆ Clock

friend class Clock
friend

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