From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/common/buffer_instrumentation.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/common/buffer_instrumentation.h (limited to 'src/common/buffer_instrumentation.h') diff --git a/src/common/buffer_instrumentation.h b/src/common/buffer_instrumentation.h new file mode 100644 index 000000000..fa1e84307 --- /dev/null +++ b/src/common/buffer_instrumentation.h @@ -0,0 +1,32 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "include/buffer.h" +#include "include/buffer_raw.h" + +namespace ceph::buffer_instrumentation { + +// this is nothing more than an intermediary for a class hierarchy which +// can placed between a user's custom raw and the `ceph::buffer::raw` to +// detect whether a given `ceph::buffer::ptr` instance wraps a particular +// raw's implementation (via `dynamic_cast` or `typeid`). +// +// users are supposed to define marker type (e.g. `class my_marker{}`). +// this marker. i +template +struct instrumented_raw : public ceph::buffer::raw { + using raw::raw; +}; + +struct instrumented_bptr : public ceph::buffer::ptr { + const ceph::buffer::raw* get_raw() const { + return _raw; + } + + template + bool is_raw_marked() const { + return dynamic_cast*>(get_raw()) != nullptr; + } +}; + +} // namespace ceph::buffer_instrumentation -- cgit v1.2.3