proxygen
|
Namespaces | |
detail | |
test | |
Classes | |
class | Barrier |
Functions | |
template<class It , class F , class ItT , class Result > | |
std::vector< Future< Result > > | map (It first, It last, F func) |
template<class It , class F , class ItT , class Result > | |
std::vector< Future< Result > > | map (Executor &exec, It first, It last, F func) |
Future< Unit > | sleep (Duration dur, Timekeeper *tk) |
template<class Collection , class F > | |
auto | map (Collection &&c, F &&func) -> decltype(map(c.begin(), c.end(), func)) |
template<class Collection , class F > | |
auto | map (Executor &exec, Collection &&c, F &&func) -> decltype(map(exec, c.begin(), c.end(), func)) |
template<class Policy , class FF > | |
invoke_result_t< FF, size_t > | retrying (Policy &&p, FF &&ff) |
std::function< bool(size_t, const exception_wrapper &)> | retryingPolicyBasic (size_t max_tries) |
template<class Policy , class URNG > | |
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) |
std::function< Future< bool >size_t, const exception_wrapper &)> | retryingPolicyCappedJitteredExponentialBackoff (size_t max_tries, Duration backoff_min, Duration backoff_max, double jitter_param) |
This namespace is for utility functions that would usually be static members of Future, except they don't make sense there because they don't depend on the template type (rather, on the type of their arguments in some cases). This is the least-bad naming scheme we could think of. Some of the functions herein have really-likely-to-collide names, like "map" and "sleep".
auto folly::futures::map | ( | Collection && | c, |
F && | func | ||
) | -> decltype(map(c.begin(), c.end(), func)) |
auto folly::futures::map | ( | Executor & | exec, |
Collection && | c, | ||
F && | func | ||
) | -> decltype(map(exec, c.begin(), c.end(), func)) |
Definition at line 84 of file helpers.h.
References c, folly::collectAllSemiFuture(), folly::pushmi::executor, folly::gen::first, int8_t, folly::makeFuture(), folly::makeFutureWith(), folly::makeSemiFuture(), folly::makeSemiFutureWith(), map(), folly::Executor::MID_PRI, folly::pushmi::detail::t, folly::T, type, value, folly::value(), and folly::via().
std::vector< Future< Result > > folly::futures::map | ( | It | first, |
It | last, | ||
F | func | ||
) |
Set func as the callback for each input Future and return a vector of Futures containing the results in the input order.
Definition at line 2358 of file Future-inl.h.
References FOLLY_GNU_DISABLE_WARNING, FOLLY_POP_WARNING, FOLLY_PUSH_WARNING, and folly::gen::move.
Referenced by complexBenchmark(), map(), and TEST().
std::vector< Future< Result > > folly::futures::map | ( | Executor & | exec, |
It | first, | ||
It | last, | ||
F | func | ||
) |
Set func as the callback for each input Future and return a vector of Futures containing the results in the input order and completing on exec.
Definition at line 2371 of file Future-inl.h.
References FOLLY_GNU_DISABLE_WARNING, FOLLY_POP_WARNING, FOLLY_PUSH_WARNING, and folly::gen::move.
invoke_result_t< FF, size_t > folly::futures::retrying | ( | Policy && | p, |
FF && | ff | ||
) |
retrying
Given a policy and a future-factory, creates futures according to the policy.
The policy must be moveable - retrying will move it a lot - and callable of either of the two forms:
We provide a few generic policies:
Custom policies may use the most recent try number and exception to decide whether to retry and optionally to do something interesting like delay before the retry. Users may pass inline lambda expressions as policies, or may define their own data types meeting the above requirements. Users are responsible for managing the lifetimes of anything pointed to or referred to from inside the policy.
For example, one custom policy may try up to k times, but only if the most recent exception is one of a few types or has one of a few error codes indicating that the failure was transitory.
Cancellation is not supported.
If both FF and Policy inline executes, then it is possible to hit a stack overflow due to the recursive nature of the retry implementation
Definition at line 234 of file Retrying.h.
References folly::futures::detail::retrying().
Referenced by TEST().
|
inline |
Definition at line 240 of file Retrying.h.
Referenced by TEST().
std::function<Future<bool>size_t, const exception_wrapper&)> folly::futures::retryingPolicyCappedJitteredExponentialBackoff | ( | size_t | max_tries, |
Duration | backoff_min, | ||
Duration | backoff_max, | ||
double | jitter_param, | ||
URNG && | rng, | ||
Policy && | p | ||
) |
Definition at line 246 of file Retrying.h.
References folly::futures::detail::retryingPolicyCappedJitteredExponentialBackoff(), and rng.
|
inline |
Definition at line 265 of file Retrying.h.
References folly::gen::move, and folly::futures::detail::retryingPolicyCappedJitteredExponentialBackoff().
Future< Unit > folly::futures::sleep | ( | Duration | , |
Timekeeper * | = nullptr |
||
) |
Returns a Future that will complete after the specified duration. The Duration typedef of a std::chrono
duration type indicates the resolution you can expect to be meaningful (milliseconds at the time of writing). Normally you wouldn't need to specify a Timekeeper, we will use the global futures timekeeper (we run a thread whose job it is to keep time for futures timeouts) but we provide the option for power users.
The Timekeeper thread will be lazily created the first time it is needed. If your program never uses any timeouts or other time-based Futures you will pay no Timekeeper thread overhead.
Definition at line 42 of file Future.cpp.
References folly::Timekeeper::after(), folly::detail::getTimekeeperSingleton(), LIKELY, and UNLIKELY.
Referenced by folly::coro::TimedWaitAwaitable< Awaitable >::await_suspend(), BENCHMARK(), folly::SemiFuture< T >::delayed(), folly::Future< T >::delayed(), wangle::ExpiringFilter< Req, Resp >::ExpiringFilter(), keepAliveTest(), RpcService::operator()(), folly::futures::detail::retryingPolicyCappedJitteredExponentialBackoff(), wangle::ExpiringFilter< Req, Resp >::startIdleTimer(), TEST(), and virtualExecutorTest().