From: Radosław Zarzyński Date: Wed, 6 Apr 2022 11:32:43 +0000 (+0200) Subject: crimson/osd: add registry of external handlers of tracking events X-Git-Tag: v18.0.0~947^2~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f5ce518f1e6b08b8b1d957ee1c1c4e905c63fe63;p=ceph-ci.git crimson/osd: add registry of external handlers of tracking events This commit intentionally fails the build. It does that to verify the static assertion on per-op-type lookup of event registry. The concrete assertion is the one about `ClientRequest` as we already moved two of its blocker into the new op tracking infra. Signed-off-by: Radosław Zarzyński --- diff --git a/src/crimson/common/operation.h b/src/crimson/common/operation.h index 31ed35ad59f..84387356ba7 100644 --- a/src/crimson/common/operation.h +++ b/src/crimson/common/operation.h @@ -158,6 +158,21 @@ private: virtual const char *get_type_name() const = 0; }; +// the main template. by default an operation has no extenral +// event handler (the empty tuple). specializing the template +// allows to define backends on per-operation-type manner. +// NOTE: basically this could be a function but C++ disallows +// differentiating return type among specializations. +template +struct EventBackendRegistry { + template static constexpr bool always_false = false; + + static std::tuple<> get_backends() { + static_assert(always_false, "Registry specialization not found"); + return {}; + } +}; + template struct Event { T* that() { @@ -172,6 +187,14 @@ struct Event { that()->internal_backend.handle(*that(), std::forward(op), std::forward(args)...); + // let's call `handle()` for concrete event type from each single + // of our backends. the order in the registry matters. + std::apply([&, //args=std::forward_as_tuple(std::forward(args)...), + this] (auto... backend) { + (..., backend.handle(*that(), + std::forward(op), + std::forward(args)...)); + }, EventBackendRegistry>::get_backends()); } };