Chatterino
Public Member Functions | List of all members
chatterino::ExponentialBackoff< maxSteps > Class Template Reference

#include <ExponentialBackoff.hpp>

Public Member Functions

 ExponentialBackoff (const std::chrono::milliseconds &start)
 
std::chrono::milliseconds next ()
 
void reset ()
 

Constructor & Destructor Documentation

◆ ExponentialBackoff()

template<unsigned maxSteps>
chatterino::ExponentialBackoff< maxSteps >::ExponentialBackoff ( const std::chrono::milliseconds &  start)
inline

Creates an object helping you make exponentially (with base 2) backed off times.

Parameters
startThe start time in milliseconds
maxStepsThe max number of progressions we will take before stopping

For example, ExponentialBackoff(10ms, 3) would have the next() function return 10ms, 20ms, 40ms, 40ms, ..., 40ms

Member Function Documentation

◆ next()

template<unsigned maxSteps>
std::chrono::milliseconds chatterino::ExponentialBackoff< maxSteps >::next ( )
inline

Return the current number in the progression and increment the step until the next one (assuming we're not at the cap)

Returns
current step in milliseconds
Here is the caller graph for this function:

◆ reset()

template<unsigned maxSteps>
void chatterino::ExponentialBackoff< maxSteps >::reset ( )
inline

Reset the progression back to its initial state

Here is the caller graph for this function:

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