userver: utils::CpuRelax Class Reference
Loading...
Searching...
No Matches
utils::CpuRelax Class Reference

#include <userver/utils/cpu_relax.hpp>

Detailed Description

Utility to yield every N iterations in a CPU-bound task to give other tasks an opportunity to get CPU time

Definition at line 33 of file cpu_relax.hpp.

Public Member Functions

 CpuRelax (std::size_t every, tracing::ScopeTime *scope)
 
 CpuRelax (const CpuRelax &)=delete
 
 CpuRelax (CpuRelax &&)=delete
 
void Relax ()
 Call this method every iteration, eventually it will yield.
 

Constructor & Destructor Documentation

◆ CpuRelax()

utils::CpuRelax::CpuRelax ( std::size_t every,
tracing::ScopeTime * scope )
explicit
Parameters
everynumber of iterations to call yield. 0 = noop
scopethe tracing::ScopeTime to pause when yielding, if any
Warning
The ScopeTime must live at least as long as the CpuRelax

The documentation for this class was generated from the following file: