From: Jérémie Galarneau Date: Fri, 21 Apr 2023 18:48:53 +0000 (-0400) Subject: Move create_unique_class util to the memory namespace X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f053d40c60b9dd38da27d88412dcac3a8404324c;p=lttng-tools.git Move create_unique_class util to the memory namespace 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 --- 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];