From: Radosław Zarzyński Date: Sat, 2 Apr 2022 12:42:35 +0000 (+0200) Subject: crimson/osd: pipeline stage classes can be bases for CRTP now X-Git-Tag: v18.0.0~947^2~44 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f5292e6f81c8eba9bde54c07a28c2a6daef62967;p=ceph.git crimson/osd: pipeline stage classes can be bases for CRTP now Signed-off-by: Radosław Zarzyński --- 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; }; - }