From 7f99a88ea9a8a6f1707fe43bee5f7cbbe7c18d59 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 21 Sep 2021 21:28:45 +0000 Subject: [PATCH] crimson/common: add safe_then_unpack() to errorated futures. 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 --- src/crimson/common/errorator.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index fbeeb39145f34..a3c26a6128c5d 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -8,6 +8,7 @@ #include +#include "crimson/common/utility.h" #include "include/ceph_assert.h" namespace crimson::interruptible { @@ -667,6 +668,19 @@ private: errorator_type::pass_further{}); } + template + 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(error_funcs)... + ); + } + template void then(Func&&) = delete; -- 2.39.5