FastMM documentation
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
backoff.hpp File Reference

Exponential backoff with jitter for reconnects: delay_n = cap_n * (1 - jitter) + U(0, cap_n * jitter) where cap_n = min(max_ms, base_ms * 2^n). More...

#include <algorithm>
#include <atomic>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <random>

Go to the source code of this file.

Classes

struct  fastmm::net::BackoffConfig
 
class  fastmm::net::ExponentialBackoff
 

Namespaces

namespace  fastmm
 
namespace  fastmm::net
 

Functions

std::uint64_t fastmm::net::backoff_seed () noexcept
 A seed no other backoff of this process, nor of another started at another time, draws.
 

Detailed Description

Exponential backoff with jitter for reconnects: delay_n = cap_n * (1 - jitter) + U(0, cap_n * jitter) where cap_n = min(max_ms, base_ms * 2^n).

jitter = 1.0 is the "full jitter" scheme (recommended: spreads a thundering herd of reconnects after a venue outage), jitter = 0 is deterministic (useful in tests).

Without a seed every object draws its own: connections that all lost the same venue spread out only when their jitter differs, and a shared seed made them retry in step.