From f053d40c60b9dd38da27d88412dcac3a8404324c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 21 Apr 2023 14:48:53 -0400 Subject: [PATCH] Move create_unique_class util to the memory namespace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit create_unique_class is helpful to write unique_ptr wrappers and is now accessed in numerous places even though it lives in the `details` namespace. Moving it to the `memory` namespace to live with other memory management facilities. Signed-off-by: Jérémie Galarneau Change-Id: Id4bb5100c1eb3a7e1e2d65f5b2d40ff8f97c786e --- include/lttng/notification/channel-internal.hpp | 2 +- include/lttng/notification/notification-internal.hpp | 2 +- src/bin/lttng-sessiond/rotation-thread.cpp | 2 +- src/bin/lttng-sessiond/session.hpp | 2 +- src/bin/lttng-sessiond/ust-registry-session.hpp | 2 +- src/bin/lttng/commands/destroy.cpp | 2 +- src/bin/lttng/utils.hpp | 2 +- src/common/make-unique-wrapper.hpp | 10 +++++----- src/common/pipe.hpp | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/lttng/notification/channel-internal.hpp b/include/lttng/notification/channel-internal.hpp index 34014f16f..173b3dcdc 100644 --- a/include/lttng/notification/channel-internal.hpp +++ b/include/lttng/notification/channel-internal.hpp @@ -87,7 +87,7 @@ struct pending_notification { struct lttng_notification_channel { using uptr = std::unique_ptr< lttng_notification_channel, - lttng::details::create_unique_class::deleter>; pthread_mutex_t lock; diff --git a/include/lttng/notification/notification-internal.hpp b/include/lttng/notification/notification-internal.hpp index 9fe471c26..36b3d7f38 100644 --- a/include/lttng/notification/notification-internal.hpp +++ b/include/lttng/notification/notification-internal.hpp @@ -24,7 +24,7 @@ struct lttng_payload_view; struct lttng_notification { using uptr = std::unique_ptr< lttng_notification, - lttng::details::create_unique_class::deleter>; struct lttng_trigger *trigger; diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index 9c92f66ab..10afaa649 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -70,7 +70,7 @@ namespace { struct rotation_thread_job { using uptr = std::unique_ptr< rotation_thread_job, - lttng::details::create_unique_class>; + lttng::memory::create_deleter_class::deleter>; enum ls::rotation_thread_job_type type; struct ltt_session *session; diff --git a/src/bin/lttng-sessiond/session.hpp b/src/bin/lttng-sessiond/session.hpp index 74be7e959..8993f9468 100644 --- a/src/bin/lttng-sessiond/session.hpp +++ b/src/bin/lttng-sessiond/session.hpp @@ -79,7 +79,7 @@ struct ltt_session { using id_t = uint64_t; using locked_ptr = std::unique_ptr::deleter>; using sptr = std::shared_ptr; diff --git a/src/bin/lttng-sessiond/ust-registry-session.hpp b/src/bin/lttng-sessiond/ust-registry-session.hpp index bfffe5b50..7f407e13a 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.hpp +++ b/src/bin/lttng-sessiond/ust-registry-session.hpp @@ -39,7 +39,7 @@ class registry_session : public lttng::sessiond::trace::trace_class { public: using locked_ptr = std::unique_ptr::deleter>; diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index 97bd1aa60..b9fd53bbf 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -110,7 +110,7 @@ cmd_error_code destroy_session(const lttng_session& session) } while (ret != 0); } - std::unique_ptr> + std::unique_ptr::deleter> stats_str; if (!session_was_already_stopped) { char *raw_stats_str = nullptr; diff --git a/src/bin/lttng/utils.hpp b/src/bin/lttng/utils.hpp index 4fa15c38d..61fb6f6ff 100644 --- a/src/bin/lttng/utils.hpp +++ b/src/bin/lttng/utils.hpp @@ -156,7 +156,7 @@ public: private: std::size_t _sessions_count; std::unique_ptr> + lttng::memory::create_deleter_class::deleter> _sessions; }; diff --git a/src/common/make-unique-wrapper.hpp b/src/common/make-unique-wrapper.hpp index 9381ce971..e49e5ced7 100644 --- a/src/common/make-unique-wrapper.hpp +++ b/src/common/make-unique-wrapper.hpp @@ -38,9 +38,9 @@ namespace lttng { * a proper, idiomatic, wrapper. */ -namespace details { +namespace memory { template -struct create_unique_class { +struct create_deleter_class { struct deleter { void operator()(WrappedType *instance) const { @@ -53,7 +53,7 @@ struct create_unique_class { return std::unique_ptr(instance); } }; -} /* namespace details */ +} /* namespace memory */ /* * 'free' is a utility function for use with make_unique_wrapper. It makes it easier to @@ -69,10 +69,10 @@ void free(Type *ptr) template std::unique_ptr::deleter> + typename memory::create_deleter_class::deleter> make_unique_wrapper(WrappedType *instance) { - const details::create_unique_class unique_deleter; + const memory::create_deleter_class unique_deleter; return unique_deleter(instance); } diff --git a/src/common/pipe.hpp b/src/common/pipe.hpp index 7c8cf89b6..9798a8cf8 100644 --- a/src/common/pipe.hpp +++ b/src/common/pipe.hpp @@ -30,7 +30,7 @@ struct lttng_pipe { using uptr = std::unique_ptr< lttng_pipe, - lttng::details::create_unique_class::deleter>; + lttng::memory::create_deleter_class::deleter>; /* Read: 0, Write: 1. */ int fd[2]; -- 2.34.1