62 template <
class Policy,
class FF>
63 invoke_result_t<FF, size_t>
retrying(Policy&& p, FF&& ff);
70 template <
class Policy>
73 using is_raw = std::is_same<result, bool>;
74 using is_fut = std::is_same<result, Future<bool>>;
75 using tag =
typename std::conditional<
78 typename std::conditional<is_fut::value, retrying_policy_fut_tag, void>
:: 82 template <
class Policy,
class FF,
class Prom>
85 using T =
typename F::value_type;
89 pm = std::forward<Policy>(p),
90 ffm = std::forward<FF>(ff)](
Try<T>&&
t)
mutable {
95 auto&
x =
t.exception();
104 }
else if (shouldRetry.
hasValue()) {
113 template <
class Policy,
class FF>
116 using T =
typename F::value_type;
118 auto f = prom.getFuture();
120 k, std::forward<Policy>(p), std::forward<FF>(ff),
std::move(prom));
124 template <
class Policy,
class FF>
128 return makeFuture<bool>(pm(k, x));
133 template <
class Policy,
class FF>
136 return retrying(0, std::forward<Policy>(p), std::forward<FF>(ff));
140 template <
class URNG>
147 auto dist = std::normal_distribution<double>(0.0, jitter_param);
148 auto jitter = std::exp(
dist(rng));
149 auto backoff_rep = jitter * backoff_min.count() * std::pow(2, n - 1);
153 auto backoff =
Duration(Duration::rep(backoff_rep));
157 template <
class Policy,
class URNG>
166 return [pm = std::forward<Policy>(p),
171 rngp = std::forward<URNG>(
rng)](
173 if (n == max_tries) {
176 return pm(n, ex).then(
177 [n, backoff_min, backoff_max, jitter_param, rngp =
std::move(rngp)](
183 n, backoff_min, backoff_max, jitter_param, rngp);
184 return futures::sleep(backoff).thenValue([](
auto&&) {
return true; });
189 template <
class Policy,
class URNG>
199 auto q = [pm = std::forward<Policy>(p)](
208 std::forward<URNG>(
rng),
212 template <
class Policy,
class URNG>
227 std::forward<URNG>(
rng),
228 std::forward<Policy>(p));
233 template <
class Policy,
class FF>
239 inline std::function<bool(size_t, const exception_wrapper&)>
244 template <
class Policy,
class URNG>
259 std::forward<URNG>(
rng),
260 std::forward<Policy>(p),
269 double jitter_param) {
std::function< Future< bool >size_t, const exception_wrapper &)> retryingPolicyCappedJitteredExponentialBackoff(size_t max_tries, Duration backoff_min, Duration backoff_max, double jitter_param, URNG &&rng, Policy &&p)
typename std::conditional< is_raw::value, retrying_policy_raw_tag, typename std::conditional< is_fut::value, retrying_policy_fut_tag, void >::type >::type tag
typename invoke_result< F, Args... >::type invoke_result_t
Duration retryingJitteredExponentialBackoffDur(size_t n, Duration backoff_min, Duration backoff_max, double jitter_param, URNG &rng)
invoke_result_t< FF, size_t > retrying(size_t k, Policy &&p, FF &&ff)
Future< Unit > sleep(Duration dur, Timekeeper *tk)
constexpr detail::Map< Move > move
std::is_same< result, bool > is_raw
exception_wrapper & exception()&
—— Concurrent Priority Queue Implementation ——
std::chrono::milliseconds Duration
void retryingImpl(size_t k, Policy &&p, FF &&ff, Prom prom)
std::uniform_int_distribution< milliseconds::rep > dist
static const char *const value
invoke_result_t< Policy, size_t, const exception_wrapper & > result
std::function< bool(size_t, const exception_wrapper &)> retryingPolicyBasic(size_t max_tries)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
Future< typename std::decay< T >::type > makeFuture(T &&t)
std::enable_if< isFuture< invoke_result_t< F > >::value, invoke_result_t< F > >::type makeFutureWith(F &&func)
invoke_result_t< FF, size_t > retrying(Policy &&p, FF &&ff)
std::is_same< result, Future< bool >> is_fut