SSX3LobbyServer/lib/base/backoff.cpp

14 lines
346 B
C++
Raw Permalink Normal View History

#include <chrono>
#include <cmath>
#include <base/backoff.hpp>
namespace base {
Awaitable<void> Backoff::Delay() {
const auto t = std::pow(base, count++);
auto timer = asio::steady_timer { co_await asio::this_coro::executor, std::chrono::seconds(static_cast<u64>(t)) };
co_await timer.async_wait(asio::deferred);
}
} // namespace base