|
VLink
2.0.0
A high-performance communication middleware
|
Stack-based RAII bracket that pairs every CpuProfiler::begin with a guaranteed end.
More...
#include "./macros.h"Go to the source code of this file.
Classes | |
| class | vlink::CpuProfilerGuard |
Scope guard that opens and closes a CpuProfiler active interval. More... | |
Namespaces | |
| vlink | |
Stack-based RAII bracket that pairs every CpuProfiler::begin with a guaranteed end.
CpuProfilerGuard ties the begin / end pair of a CpuProfiler to scope lifetime so the active interval closes even when the protected region exits through an exception.
* scope entry +---------------------------+ scope exit * ----------> | CpuProfilerGuard guard(p) | ----------> * +-----------+---------------+ * | ctor: p->begin() * v * active interval * | * | dtor: p->end() * v * interval closed *
The guard accepts a nullptr profiler so call sites can be guarded uniformly while a higher-level switch (typically CpuProfiler::is_global_enabled) decides whether the work is worth measuring.