crimson: dissect error handling path from ::safe_then().

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
This commit is contained in:
Radoslaw Zarzynski 2019-09-29 03:49:32 +02:00
parent 648e61b874
commit 60bceaba7f

View File

@ -353,6 +353,18 @@ private:
using base_t::base_t;
template <class Futurator, class ErrorVisitor>
[[gnu::noinline]]
static auto _safe_then_handle_errors(auto&& future,
ErrorVisitor&& errfunc) {
maybe_handle_error_t<ErrorVisitor, Futurator> maybe_handle_error(
std::forward<ErrorVisitor>(errfunc),
std::move(future).get_exception()
);
(maybe_handle_error.template handle<AllowedErrors>() , ...);
return std::move(maybe_handle_error).get_result();
}
public:
using errorator_type = ::crimson::errorator<AllowedErrors...>;
using promise_type = seastar::promise<ValuesT...>;
@ -456,12 +468,8 @@ private:
errfunc = std::forward<ErrorVisitorT>(errfunc)
] (auto&& future) mutable [[gnu::always_inline]] noexcept {
if (__builtin_expect(future.failed(), false)) {
maybe_handle_error_t<ErrorVisitorT, futurator_t> maybe_handle_error(
std::forward<ErrorVisitorT>(errfunc),
std::move(future).get_exception()
);
(maybe_handle_error.template handle<AllowedErrors>() , ...);
return std::move(maybe_handle_error).get_result();
return _safe_then_handle_errors<futurator_t>(
std::move(future), std::forward<ErrorVisitorT>(errfunc));
} else {
// NOTE: using `seastar::future::get()` here is a bit bloaty
// as the method rechecks availability of future's value and,