From 6a538c21f071f1b22afce679351bd0264d7cfaa1 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 25 Jan 2024 13:54:00 +0800 Subject: [PATCH] crimson/common/operation: cleanup around PipelineHandle::enter() Signed-off-by: Yingxin Cheng --- src/crimson/common/operation.h | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/crimson/common/operation.h b/src/crimson/common/operation.h index 82d0d548442e8..938db0c87c8ee 100644 --- a/src/crimson/common/operation.h +++ b/src/crimson/common/operation.h @@ -492,11 +492,6 @@ public: #ifndef NDEBUG const core_id_t core = seastar::this_shard_id(); #endif - - template - decltype(auto) enter(Args&&... args) { - return static_cast(this)->enter(std::forward(args)...); - } }; class PipelineHandle { @@ -506,6 +501,18 @@ class PipelineHandle { return barrier ? barrier->wait() : std::nullopt; } + template + seastar::future<> + do_enter(T &stage, typename T::BlockingEvent::template Trigger&& t) { + auto fut = t.maybe_record_blocking(stage.enter(t), stage); + return std::move(fut).then( + [this, t=std::move(t)](auto &&barrier_ref) mutable { + exit(); + barrier = std::move(barrier_ref); + return seastar::now(); + }); + } + public: PipelineHandle() = default; @@ -526,23 +533,12 @@ public: assert(stage.core == seastar::this_shard_id()); auto wait_fut = wait_barrier(); if (wait_fut.has_value()) { - return wait_fut.value().then([this, &stage, t=std::move(t)] () mutable { - auto fut = t.maybe_record_blocking(stage.enter(t), stage); - return std::move(fut).then( - [this, t=std::move(t)](auto &&barrier_ref) mutable { - exit(); - barrier = std::move(barrier_ref); - return seastar::now(); - }); + return wait_fut.value( + ).then([this, &stage, t=std::move(t)]() mutable { + return do_enter(stage, std::move(t)); }); } else { - auto fut = t.maybe_record_blocking(stage.enter(t), stage); - return std::move(fut).then( - [this, t=std::move(t)](auto &&barrier_ref) mutable { - exit(); - barrier = std::move(barrier_ref); - return seastar::now(); - }); + return do_enter(stage, std::move(t)); } } -- 2.39.5