14 lines
346 B
C++
14 lines
346 B
C++
#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
|