]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: dissect error handling path from ::safe_then().
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 29 Sep 2019 01:49:32 +0000 (03:49 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 20 Nov 2019 19:37:44 +0000 (20:37 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/common/errorator.h

index d07c48c7d5a686f939e9d2b36f2da24d0f5a4a8e..36de9770078c37f84faa7339f9208463fb1e542b 100644 (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,