join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Backoff Class Reference

adaptive backoff for busy-wait loops, requires Rdtsc::calibrate (). More...

#include <backoff.hpp>

Public Member Functions

 Backoff (std::chrono::nanoseconds spin=std::chrono::microseconds(10), std::chrono::nanoseconds yield=std::chrono::microseconds(100), std::chrono::nanoseconds sleep=std::chrono::microseconds(50)) noexcept
 construct a backoff strategy.
 
void operator() () noexcept
 execute one backoff iteration.
 
void reset () noexcept
 reset backoff to initial state.
 
bool spinExhausted () const noexcept
 check if initial spin phase is over.
 

Detailed Description

adaptive backoff for busy-wait loops, requires Rdtsc::calibrate ().

Constructor & Destructor Documentation

◆ Backoff()

join::Backoff::Backoff ( std::chrono::nanoseconds spin = std::chrono::microseconds (10),
std::chrono::nanoseconds yield = std::chrono::microseconds (100),
std::chrono::nanoseconds sleep = std::chrono::microseconds (50) )
inlineexplicitnoexcept

construct a backoff strategy.

Parameters
spinspin duration.
yieldyield duration.
sleepsleep per iteration, zero to never sleep.

Member Function Documentation

◆ operator()()

void join::Backoff::operator() ( )
inlinenoexcept

execute one backoff iteration.

◆ reset()

void join::Backoff::reset ( )
inlinenoexcept

reset backoff to initial state.

◆ spinExhausted()

bool join::Backoff::spinExhausted ( ) const
inlinenoexcept

check if initial spin phase is over.

Returns
true if initial spin phase is over.

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