From: Radoslaw Zarzynski Date: Tue, 21 Sep 2021 21:28:45 +0000 (+0000) Subject: crimson/common: add safe_then_unpack() to errorated futures. X-Git-Tag: v17.1.0~834^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7f99a88ea9a8a6f1707fe43bee5f7cbbe7c18d59;p=ceph.git 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 --- 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;