Skip to main content

chronon::observe::ThreadContext

More...

#include <ThreadContext.hpp>

Public Functions

Name
SizeCacheVector &sizeCache()
SPSCQueue &queue()
const SPSCQueue &queue() const
ThreadContext &operator=(const ThreadContext & ) =delete
ThreadContext &operator=(ThreadContext && ) =delete
boolisActive() const
voidincrementDropped()
uint32_tid() const
uint64_tdroppedCount() const
ThreadContext(uint32_t id, size_t queue_capacity =SPSCQueue::DEFAULT_CAPACITY)
ThreadContext(const ThreadContext & ) =delete
ThreadContext(ThreadContext && ) =delete

Detailed Description

class chronon::observe::ThreadContext;

ThreadContext - Per-thread state for observability.

Each simulation thread that emits traces/logs gets its own ThreadContext with a dedicated SPSC queue. This eliminates mutex contention between threads.

The ThreadContext is allocated once per thread (on first use) and reused for the lifetime of the thread.

Public Functions Documentation

function sizeCache

inline SizeCacheVector & sizeCache()

Get the string length cache for this thread.

Used to cache strlen() results during two-phase encoding:

  1. Size calculation phase: compute and cache string lengths
  2. Encoding phase: use cached lengths (no redundant strlen)

function queue

inline SPSCQueue & queue()

Get the dedicated SPSC queue for this thread.

Hot path - direct access, no synchronization needed since queue is owned by this thread.

function queue

inline const SPSCQueue & queue() const

function operator=

ThreadContext & operator=(
const ThreadContext &
) =delete

function operator=

ThreadContext & operator=(
ThreadContext &&
) =delete

function isActive

inline bool isActive() const

Check if this context is active (has written any data).

function incrementDropped

inline void incrementDropped()

Increment dropped event counter.

function id

inline uint32_t id() const

Get the thread context ID.

function droppedCount

inline uint64_t droppedCount() const

Get number of dropped events.

function ThreadContext

inline explicit ThreadContext(
uint32_t id,
size_t queue_capacity =SPSCQueue::DEFAULT_CAPACITY
)

Parameters:

  • id Unique thread context ID (assigned by ThreadContextManager)
  • queue_capacity Capacity of the SPSC queue in bytes

Construct a thread context with the given ID.

function ThreadContext

ThreadContext(
const ThreadContext &
) =delete

function ThreadContext

ThreadContext(
ThreadContext &&
) =delete

Updated on 2026-05-26 at 05:42:33 +0000