26 #include <olp/core/CoreApi.h>
58 std::chrono::milliseconds initial_backdown_period,
size_t retry_count) {
59 const auto exponential_wait_time =
60 initial_backdown_period.count() * (
size_t{1} << retry_count);
62 static thread_local std::mt19937 kGenerator(std::random_device{}());
63 std::uniform_int_distribution<std::chrono::milliseconds::rep> dist(
64 0, exponential_wait_time);
65 return std::chrono::milliseconds(dist(kGenerator));
90 std::chrono::milliseconds cap = std::chrono::seconds(1))
103 std::chrono::milliseconds initial_backdown_period,
size_t retry_count) {
105 constexpr
size_t max_retry_count = 30u;
106 retry_count = std::min<size_t>(retry_count, max_retry_count);
107 const int64_t exponential_wait_time =
108 initial_backdown_period.count() * (1ull << retry_count);
109 static thread_local std::mt19937 kGenerator(std::random_device{}());
110 const auto temp = std::min<int64_t>(cap_.count(), exponential_wait_time);
111 std::uniform_int_distribution<int64_t> dist(0, temp / 2);
112 const auto sleep = temp / 2 + dist(kGenerator);
113 return std::chrono::milliseconds(sleep);
117 std::chrono::milliseconds cap_;
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Computes wait time for the next retry attempt via the exponential backoff with the added jitter.
Definition: BackdownStrategy.h:82
EqualJitterBackdownStrategy(std::chrono::milliseconds cap=std::chrono::seconds(1))
Creates a EqualJitterBackdownStrategy instance.
Definition: BackdownStrategy.h:89
std::chrono::milliseconds operator()(std::chrono::milliseconds initial_backdown_period, size_t retry_count)
Computes the next retry attempt wait time based on the number of retries and initial backdown period.
Definition: BackdownStrategy.h:102
Computes wait time for the next retry attempt via the exponential backoff with the added jitter.
Definition: BackdownStrategy.h:46
std::chrono::milliseconds operator()(std::chrono::milliseconds initial_backdown_period, size_t retry_count)
Computes the next retry attempt wait time based on the number of retries and initial backdown period.
Definition: BackdownStrategy.h:57