21 lines
391 B
C++
21 lines
391 B
C++
#pragma once
|
|
#include <base/types.hpp>
|
|
|
|
namespace base {
|
|
|
|
/// Exponential backoff implementation.
|
|
/// Backoff time is calculated using the classicial t = bᶜ formula.
|
|
struct Backoff {
|
|
explicit constexpr Backoff(double base = 2.) : base(base) {};
|
|
|
|
Awaitable<void> Delay();
|
|
|
|
inline void Reset() { count = 0; }
|
|
|
|
private:
|
|
double base {};
|
|
u32 count {};
|
|
};
|
|
|
|
} // namespace base
|