SSX3LobbyServer/lib/base/backoff.hpp

21 lines
391 B
C++
Raw Normal View History

#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