|
VLink
2.0.0
A high-performance communication middleware
|
Stack-based RAII bracket that pairs every CpuProfiler::begin with a guaranteed end.
更多...
#include "./macros.h"类 | |
| class | vlink::CpuProfilerGuard |
Scope guard that opens and closes a CpuProfiler active interval. 更多... | |
命名空间 | |
| 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.