QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ExponentialBackoff Class Reference

Retry delays that start at an initial value and grow by a factor per attempt, up to a cap. More...

#include <ExponentialBackoff.h>

Public Types

using Delay = std::chrono::milliseconds
 

Public Member Functions

constexpr ExponentialBackoff (Delay initial, double factor, Delay cap, Delay maxRetryAfter=Delay::zero())
 A positive maxRetryAfter lets a server's retry-after hint lengthen a delay, up to that limit.
 
constexpr Delay peek (Delay retryAfter=Delay::zero()) const
 
constexpr Delay next (Delay retryAfter=Delay::zero())
 Returns peek(retryAfter) and counts the attempt.
 
constexpr void reset ()
 
constexpr int attempts () const
 Attempts counted since construction or the last reset().
 

Detailed Description

Retry delays that start at an initial value and grow by a factor per attempt, up to a cap.

Definition at line 7 of file ExponentialBackoff.h.

Member Typedef Documentation

◆ Delay

using ExponentialBackoff::Delay = std::chrono::milliseconds

Definition at line 10 of file ExponentialBackoff.h.

Constructor & Destructor Documentation

◆ ExponentialBackoff()

constexpr ExponentialBackoff::ExponentialBackoff ( Delay  initial,
double  factor,
Delay  cap,
Delay  maxRetryAfter = Delay::zero() 
)
inlineconstexpr

A positive maxRetryAfter lets a server's retry-after hint lengthen a delay, up to that limit.

Definition at line 13 of file ExponentialBackoff.h.

Member Function Documentation

◆ attempts()

constexpr int ExponentialBackoff::attempts ( ) const
inlineconstexpr

Attempts counted since construction or the last reset().

Definition at line 45 of file ExponentialBackoff.h.

◆ next()

constexpr Delay ExponentialBackoff::next ( Delay  retryAfter = Delay::zero())
inlineconstexpr

Returns peek(retryAfter) and counts the attempt.

Definition at line 29 of file ExponentialBackoff.h.

References peek().

◆ peek()

constexpr Delay ExponentialBackoff::peek ( Delay  retryAfter = Delay::zero()) const
inlineconstexpr

The delay before the next attempt. A retryAfter hint longer than the exponential delay replaces it, clamped to maxRetryAfter.

Definition at line 23 of file ExponentialBackoff.h.

Referenced by next().

◆ reset()

constexpr void ExponentialBackoff::reset ( )
inlineconstexpr

Definition at line 38 of file ExponentialBackoff.h.

Referenced by GPSReceiverConnectionPolicy::receiverReady().


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