mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
mal_toolkit::LinearBackoff< ChronoType > Class Template Reference

A utility class for implementing linear backoff strategies. More...

#include "backoffs.hpp"

Collaboration diagram for mal_toolkit::LinearBackoff< ChronoType >:
[legend]

Public Member Functions

constexpr LinearBackoff (ChronoType initial_delay, ChronoType max_delay, ChronoType step)
 Constructor to initialize the linear backoff strategy.
 
constexpr ChronoType get_current_delay () const noexcept
 Get the current backoff delay.
 
constexpr double get_current_delay_double () const noexcept
 Get the current backoff delay as a double.
 
constexpr void increase_delay () noexcept
 Increase the backoff delay using the specified step.
 
constexpr void decrease_delay () noexcept
 Decrease the backoff delay using the specified step.
 
constexpr void reset_delay () noexcept
 Reset the backoff delay to its initial value.
 

Private Attributes

const ChronoType initial_delay_
 The initial delay before the first retry.
 
const ChronoType max_delay_
 The maximum delay allowed between retries.
 
const ChronoType step_
 The increment step used to increase or decrease the delay.
 
ChronoType current_delay_
 The current backoff delay.
 

Detailed Description

template<typename ChronoType>
class mal_toolkit::LinearBackoff< ChronoType >

A utility class for implementing linear backoff strategies.

Linear backoff is a strategy where the delay between retries increases linearly. This class provides functionality to manage and manipulate the backoff delay.

Template Parameters
ChronoTypeThe type representing the time duration (e.g., std::chrono::milliseconds).

Definition at line 110 of file backoffs.hpp.

Constructor & Destructor Documentation

◆ LinearBackoff()

template<typename ChronoType >
mal_toolkit::LinearBackoff< ChronoType >::LinearBackoff ( ChronoType initial_delay,
ChronoType max_delay,
ChronoType step )
inlineconstexpr

Constructor to initialize the linear backoff strategy.

Parameters
initial_delayThe initial delay before the first retry.
max_delayThe maximum delay allowed between retries.
stepThe increment step used to increase or decrease the delay.

Definition at line 120 of file backoffs.hpp.

Member Function Documentation

◆ decrease_delay()

template<typename ChronoType >
void mal_toolkit::LinearBackoff< ChronoType >::decrease_delay ( )
inlineconstexprnoexcept

Decrease the backoff delay using the specified step.

Definition at line 150 of file backoffs.hpp.

◆ get_current_delay()

template<typename ChronoType >
ChronoType mal_toolkit::LinearBackoff< ChronoType >::get_current_delay ( ) const
inlineconstexprnoexcept

Get the current backoff delay.

Returns
The current backoff delay.

Definition at line 130 of file backoffs.hpp.

◆ get_current_delay_double()

template<typename ChronoType >
double mal_toolkit::LinearBackoff< ChronoType >::get_current_delay_double ( ) const
inlineconstexprnoexcept

Get the current backoff delay as a double.

Returns
The current backoff delay with applied jitter.

Definition at line 137 of file backoffs.hpp.

◆ increase_delay()

template<typename ChronoType >
void mal_toolkit::LinearBackoff< ChronoType >::increase_delay ( )
inlineconstexprnoexcept

Increase the backoff delay using the specified step.

Definition at line 145 of file backoffs.hpp.

◆ reset_delay()

template<typename ChronoType >
void mal_toolkit::LinearBackoff< ChronoType >::reset_delay ( )
inlineconstexprnoexcept

Reset the backoff delay to its initial value.

Definition at line 155 of file backoffs.hpp.

Member Data Documentation

◆ current_delay_

template<typename ChronoType >
ChronoType mal_toolkit::LinearBackoff< ChronoType >::current_delay_
private

The current backoff delay.

Definition at line 161 of file backoffs.hpp.

◆ initial_delay_

template<typename ChronoType >
const ChronoType mal_toolkit::LinearBackoff< ChronoType >::initial_delay_
private

The initial delay before the first retry.

Definition at line 158 of file backoffs.hpp.

◆ max_delay_

template<typename ChronoType >
const ChronoType mal_toolkit::LinearBackoff< ChronoType >::max_delay_
private

The maximum delay allowed between retries.

Definition at line 159 of file backoffs.hpp.

◆ step_

template<typename ChronoType >
const ChronoType mal_toolkit::LinearBackoff< ChronoType >::step_
private

The increment step used to increase or decrease the delay.

Definition at line 160 of file backoffs.hpp.


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