From f5292e6f81c8eba9bde54c07a28c2a6daef62967 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rados=C5=82aw=20Zarzy=C5=84ski?= Date: Sat, 2 Apr 2022 14:42:35 +0200 Subject: [PATCH] crimson/osd: pipeline stage classes can be bases for CRTP now MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Radosław Zarzyński --- src/crimson/common/operation.cc | 8 ------ src/crimson/common/operation.h | 44 +++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/crimson/common/operation.cc b/src/crimson/common/operation.cc index fc49046963fa6..85575a74a0efa 100644 --- a/src/crimson/common/operation.cc +++ b/src/crimson/common/operation.cc @@ -67,12 +67,4 @@ void AggregateBlocker::dump_detail(ceph::Formatter *f) const f->close_section(); } -void OrderedExclusivePhase::dump_detail(ceph::Formatter* f) const -{ -} - -void OrderedConcurrentPhase::dump_detail(ceph::Formatter* f) const -{ -} - } diff --git a/src/crimson/common/operation.h b/src/crimson/common/operation.h index 2bc5f5d1e9da2..4fcfcbd812763 100644 --- a/src/crimson/common/operation.h +++ b/src/crimson/common/operation.h @@ -558,13 +558,14 @@ public: * resolve) a new phase prior to exiting the previous one will ensure that * the op ordering is preserved. */ -class OrderedExclusivePhase : public PipelineStageIT { - void dump_detail(ceph::Formatter *f) const final; +template +class OrderedExclusivePhaseT : public PipelineStageIT { + void dump_detail(ceph::Formatter *f) const final {} class ExitBarrier final : public PipelineExitBarrierI { - OrderedExclusivePhase *phase; + OrderedExclusivePhaseT *phase; public: - ExitBarrier(OrderedExclusivePhase *phase) : phase(phase) {} + ExitBarrier(OrderedExclusivePhaseT *phase) : phase(phase) {} seastar::future<> wait() final { return seastar::now(); @@ -597,28 +598,31 @@ public: }); } - OrderedExclusivePhase(const char *type_name) : type_name(type_name) {} - - const char * type_name; - private: seastar::shared_mutex mutex; }; +// TODO: drop this after migrating to the new event tracking infrastructure. +struct OrderedExclusivePhase : OrderedExclusivePhaseT { + OrderedExclusivePhase(const char *type_name) : type_name(type_name) {} + const char * type_name; +}; + /** * Permits multiple ops to inhabit the stage concurrently, but ensures that * they will proceed to the next stage in the order in which they called * enter. */ -class OrderedConcurrentPhase : public PipelineStageIT { - void dump_detail(ceph::Formatter *f) const final; +template +class OrderedConcurrentPhaseT : public PipelineStageIT { + void dump_detail(ceph::Formatter *f) const final {} class ExitBarrier final : public PipelineExitBarrierI { - OrderedConcurrentPhase *phase; + OrderedConcurrentPhaseT *phase; std::optional> barrier; public: ExitBarrier( - OrderedConcurrentPhase *phase, + OrderedConcurrentPhaseT *phase, seastar::future<> &&barrier) : phase(phase), barrier(std::move(barrier)) {} seastar::future<> wait() final { @@ -657,20 +661,22 @@ public: new ExitBarrier{this, mutex.lock()}); } - OrderedConcurrentPhase(const char *type_name) : type_name(type_name) {} - - const char * type_name; - private: seastar::shared_mutex mutex; }; +struct OrderedConcurrentPhase : OrderedConcurrentPhaseT { + OrderedConcurrentPhase(const char *type_name) : type_name(type_name) {} + const char * type_name; +}; + /** * Imposes no ordering or exclusivity at all. Ops enter without constraint and * may exit in any order. Useful mainly for informational purposes between * stages with constraints. */ -class UnorderedStage : public PipelineStageIT { +template +class UnorderedStageT : public PipelineStageIT { void dump_detail(ceph::Formatter *f) const final {} class ExitBarrier final : public PipelineExitBarrierI { @@ -693,11 +699,11 @@ public: return seastar::make_ready_future( new ExitBarrier); } +}; +struct UnorderedStage : UnorderedStageT { UnorderedStage(const char *type_name) : type_name(type_name) {} - const char * type_name; }; - } -- 2.39.5