]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common: add safe_then_unpack() to errorated futures. 43247/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 21 Sep 2021 21:28:45 +0000 (21:28 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 21 Sep 2021 21:34:00 +0000 (21:34 +0000)
It was a prerequisite for another commit I finally thrown
away. However, this little bit can be still be useful even
for the sake of compliance with the interruptible variant.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/common/errorator.h

index fbeeb39145f3454664369b5fc6b6da9b7f31ac64..a3c26a6128c5d2f98989fa14b201a8013b371410 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <seastar/core/future-util.hh>
 
+#include "crimson/common/utility.h"
 #include "include/ceph_assert.h"
 
 namespace crimson::interruptible {
@@ -667,6 +668,19 @@ private:
                        errorator_type::pass_further{});
     }
 
+    template <class ValueFunc,
+              class... ErrorFuncs>
+    auto safe_then_unpack(ValueFunc&& value_func,
+                          ErrorFuncs&&... error_funcs) {
+      return safe_then(
+        [value_func=std::move(value_func)] (ValueT&& tuple) mutable {
+          assert_moveable(value_func);
+          return std::apply(std::move(value_func), std::move(tuple));
+        },
+        std::forward<ErrorFuncs>(error_funcs)...
+      );
+    }
+
     template <class Func>
     void then(Func&&) = delete;