Thread-local context management for request tracking.
More...
#include <thread_context.h>
Thread-local context management for request tracking.
Manages a thread_context_data instance in thread-local storage. Each thread has its own independent context, so no locking is required. Use create() to initialize a context at the start of request processing, and clear() to release it when done.
}
static std::string generate_correlation_id()
Generate a unique correlation ID.
static void clear()
Clear and destroy the current thread-local context.
static thread_context_data * current()
Get the current thread-local context.
static thread_context_data & create(const std::string &request_id="")
Create a new thread-local context, replacing any existing one.
static bool has_context()
Check whether a context exists on the current thread.
- See also
- thread_context_data For the stored context data structure
Definition at line 175 of file thread_context.h.
◆ clear()
| static void kcenon::monitoring::thread_context::clear |
( |
| ) |
|
|
static |
◆ copy_from()
| static bool kcenon::monitoring::thread_context::copy_from |
( |
const thread_context_data & | source | ) |
|
|
static |
Copy context data from another source into the current thread.
- Parameters
-
| source | The context data to copy from |
- Returns
- true if the copy succeeded, false on failure
Referenced by TEST_F().
◆ create()
| static thread_context_data & kcenon::monitoring::thread_context::create |
( |
const std::string & | request_id = "" | ) |
|
|
static |
◆ current()
◆ generate_correlation_id()
| static std::string kcenon::monitoring::thread_context::generate_correlation_id |
( |
| ) |
|
|
static |
◆ generate_request_id()
| static std::string kcenon::monitoring::thread_context::generate_request_id |
( |
| ) |
|
|
static |
◆ has_context()
| static bool kcenon::monitoring::thread_context::has_context |
( |
| ) |
|
|
static |
◆ current_context_
| thread_local std::unique_ptr<thread_context_data> kcenon::monitoring::thread_context::current_context_ |
|
staticprivate |
The documentation for this class was generated from the following file: