From: Xuehan Xu Date: Thu, 13 May 2021 08:52:11 +0000 (+0800) Subject: crimson/common: add new facilities to interruptible future X-Git-Tag: v17.1.0~1944^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a0eaf67fec78492f53e80eebde8b0554b391bc68;p=ceph.git crimson/common: add new facilities to interruptible future Signed-off-by: Xuehan Xu --- diff --git a/src/crimson/common/interruptible_future.h b/src/crimson/common/interruptible_future.h index e2cb8b541026..5c64a514bcb1 100644 --- a/src/crimson/common/interruptible_future.h +++ b/src/crimson/common/interruptible_future.h @@ -669,6 +669,22 @@ public: return (interrupt_futurize_t)(std::move(fut)); } + template + [[gnu::always_inline]] + auto safe_then_unpack_interruptible(ValFuncT&& func, ErrorFuncT&& errfunc) { + return safe_then_interruptible([func=std::forward(func)](T&& tuple) mutable { + return std::apply(std::forward(func), std::move(tuple)); + }, std::forward(errfunc)); + } + + template + [[gnu::always_inline]] + auto safe_then_unpack_interruptible(ValFuncT&& func) { + return safe_then_interruptible([func=std::forward(func)](T&& tuple) mutable { + return std::apply(std::forward(func), std::move(tuple)); + }); + } + template && interruptible, int> = 0> [[gnu::always_inline]] @@ -707,6 +723,22 @@ public: std::forward(err_func_tail)...)); } + template + [[gnu::always_inline]] + auto safe_then_unpack_interruptible_tuple( + ValFuncT&& valfunc, + ErrorVisitorHeadT&& err_func_head, + ErrorVisitorTailT&&... err_func_tail) { + return safe_then_interruptible_tuple( + [valfunc=std::forward(valfunc)](T&& tuple) mutable { + return std::apply(std::forward(valfunc), std::move(tuple)); + }, + ::crimson::composer(std::forward(err_func_head), + std::forward(err_func_tail)...)); + } + template auto handle_error_interruptible(ErrorFunc&& errfunc) { if constexpr (interruptible) { @@ -830,6 +862,14 @@ public: seastar::future<>>(seastar::now()); } + template + [[gnu::always_inline]] + static interruptible_future_detail> + make_ready_future(A&&... value) { + return interruptible_future_detail>( + seastar::make_ready_future(std::forward(value)...)); + } + template struct futurize { using type = interruptible_future_detail<