quill
Classes | Public Types | Static Public Member Functions | Static Public Attributes | List of all members
BackendTscClock Class Reference

A utility class for accessing the Time Stamp Counter (TSC) clock used by the backend logging thread. More...

#include <BackendTscClock.h>

Classes

class  RdtscVal
 

Public Types

using duration = std::chrono::nanoseconds
 
using rep = duration::rep
 
using period = duration::period
 
using time_point = std::chrono::time_point< BackendTscClock, duration >
 

Static Public Member Functions

QUILL_NODISCARD static QUILL_ATTRIBUTE_HOT time_point now () noexcept
 Provides the current synchronized timestamp obtained using the TSC clock maintained by the backend logging thread. More...
 
QUILL_NODISCARD static QUILL_ATTRIBUTE_HOT RdtscVal rdtsc () noexcept
 Returns the current value of the TSC timer maintained by the backend logging thread. More...
 
QUILL_NODISCARD static QUILL_ATTRIBUTE_HOT time_point to_time_point (RdtscVal rdtsc) noexcept
 Converts a TSC (Time Stamp Counter) value to a wall clock timestamp. More...
 

Static Public Attributes

static constexpr bool is_steady = false
 

Detailed Description

A utility class for accessing the Time Stamp Counter (TSC) clock used by the backend logging thread.

This class provides access to the TSC clock maintained by the backend logging thread, allowing for synchronized timestamp retrieval.

Other threads can obtain timestamps synchronized with the TSC clock of the backend logging thread, ensuring synchronization with log statement timestamps.

If ClockSourceType::Tsc is not used by any Logger, this class reverts to using the system clock for providing a timestamp.

Note
For more accurate timestamps, consider reducing rdtsc_resync_interval in BackendOptions.
All methods of the class are thread-safe.

Member Function Documentation

◆ now()

QUILL_NODISCARD static QUILL_ATTRIBUTE_HOT time_point BackendTscClock::now ( )
inlinestaticnoexcept

Provides the current synchronized timestamp obtained using the TSC clock maintained by the backend logging thread.

Returns
A wall clock timestamp in nanoseconds since epoch, synchronized with the backend logging thread's TSC clock.

◆ rdtsc()

QUILL_NODISCARD static QUILL_ATTRIBUTE_HOT RdtscVal BackendTscClock::rdtsc ( )
inlinestaticnoexcept

Returns the current value of the TSC timer maintained by the backend logging thread.

Returns
The current value of the TSC timer.

◆ to_time_point()

QUILL_NODISCARD static QUILL_ATTRIBUTE_HOT time_point BackendTscClock::to_time_point ( RdtscVal  rdtsc)
inlinestaticnoexcept

Converts a TSC (Time Stamp Counter) value to a wall clock timestamp.

Parameters
rdtscThe TSC counter value
Warning
This function will return 0 if no Logger with a TSC clock source has been used. The TSC clock is initialized by the backend thread when the first log statement is processed, provided that a TSC-based logger is used. If the backend thread has not processed any log statements, the function may return zero.
Returns
The time since the Unix epoch, in nanoseconds, corresponding to the given TSC counter value.

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