Skip to main content

chronon::observe::ThreadContextManager

Singleton managing per-thread observability contexts. More...

#include <ThreadContextManager.hpp>

Public Functions

Name
boolwakeBackend()
Safe to call from any producer thread.
uint64_ttotalDroppedCount() const
voidsetQueueCapacity(size_t capacity)
PRECONDITION: must be called before any thread calls getContext().
voidsetBackpressurePolicy(BackpressurePolicy policy)
PRECONDITION: must be called before any thread calls getContext().
voidsetBackpressurePolicy(ObservationChannel ch, BackpressurePolicy policy)
voidsetBackpressureMaxSpins(uint32_t max_spins)
voidsetBackpressureMaxSpins(ObservationChannel ch, uint32_t max_spins)
voidsetBackendWakeup(void(*)(void *) fn, void * ctx)
Register a callback the backend uses to be woken by producers.
size_tqueueCapacity() const
boolisInitialized() const
ThreadContextManager &instance()
ThreadContext *getContext()
Get or create the calling thread's context.
template <typename Fn >
void
forEachContext(Fn && fn)
Thread-safe; safe to call while other threads are using their contexts.
voidflushAll()
Force-publish writer positions on all queues. Used during shutdown.
BackpressurePolicybackpressurePolicy() const
BackpressurePolicybackpressurePolicy(ObservationChannel ch) const
uint32_tbackpressureMaxSpins() const
uint32_tbackpressureMaxSpins(ObservationChannel ch) const
size_tactiveThreadCount() const

Public Attributes

Name
size_tMAX_THREADS

Detailed Description

class chronon::observe::ThreadContextManager;

Singleton managing per-thread observability contexts.

Pre-allocated context pool, thread-local pointer cache, lock-free hot path.

Public Functions Documentation

function wakeBackend

inline bool wakeBackend()

Safe to call from any producer thread.

function totalDroppedCount

inline uint64_t totalDroppedCount() const

function setQueueCapacity

inline void setQueueCapacity(
size_t capacity
)

PRECONDITION: must be called before any thread calls getContext().

function setBackpressurePolicy

inline void setBackpressurePolicy(
BackpressurePolicy policy
)

PRECONDITION: must be called before any thread calls getContext().

function setBackpressurePolicy

inline void setBackpressurePolicy(
ObservationChannel ch,
BackpressurePolicy policy
)

function setBackpressureMaxSpins

inline void setBackpressureMaxSpins(
uint32_t max_spins
)

function setBackpressureMaxSpins

inline void setBackpressureMaxSpins(
ObservationChannel ch,
uint32_t max_spins
)

function setBackendWakeup

inline void setBackendWakeup(
void(*)(void *) fn,
void * ctx
)

Register a callback the backend uses to be woken by producers.

Indirected through atomics to avoid a circular header dependency. Written once at startup, read on hot path — acquire/release suffices.

function queueCapacity

inline size_t queueCapacity() const

function isInitialized

inline bool isInitialized() const

function instance

static inline ThreadContextManager & instance()

function getContext

inline ThreadContext * getContext()

Get or create the calling thread's context.

Return: Thread context, or nullptr if MAX_THREADS exceeded.

function forEachContext

template <typename Fn >
inline void forEachContext(
Fn && fn
)

Thread-safe; safe to call while other threads are using their contexts.

function flushAll

inline void flushAll()

Force-publish writer positions on all queues. Used during shutdown.

function backpressurePolicy

inline BackpressurePolicy backpressurePolicy() const

function backpressurePolicy

inline BackpressurePolicy backpressurePolicy(
ObservationChannel ch
) const

function backpressureMaxSpins

inline uint32_t backpressureMaxSpins() const

function backpressureMaxSpins

inline uint32_t backpressureMaxSpins(
ObservationChannel ch
) const

function activeThreadCount

inline size_t activeThreadCount() const

Public Attributes Documentation

variable MAX_THREADS

static size_t MAX_THREADS = 64;

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