chronon::observe::ThreadContext
#include <ThreadContext.hpp>
Public Functions
| Name | |
|---|---|
| SizeCacheVector & | sizeCache() |
| SPSCQueue & | queue() |
| const SPSCQueue & | queue() const |
| ThreadContext & | operator=(const ThreadContext & ) =delete |
| ThreadContext & | operator=(ThreadContext && ) =delete |
| bool | isActive() const |
| void | incrementDropped() |
| uint32_t | id() const |
| uint64_t | droppedCount() 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:
- Size calculation phase: compute and cache string lengths
- 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