Nanotrace: Make category uncopyable

Leads to subtle bugs.

Task-number: QDS-11952
Change-Id: I022af297e89a08d9ed98cee6b76c6e2114043987
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2024-02-15 08:21:07 +01:00
parent 4b0ea7b8fd
commit 1b64158c7a

View File

@@ -657,7 +657,7 @@ public:
std::size_t bindId = 0; std::size_t bindId = 0;
if (m_id) { if (m_id) {
auto category = m_category(); auto &category = m_category();
bindId = category.createBindId(); bindId = category.createBindId();
category.begin('b', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...); category.begin('b', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...);
} }
@@ -954,12 +954,12 @@ public:
std::size_t bindId = 0; std::size_t bindId = 0;
if (m_id) { if (m_id) {
auto category = m_category(); auto &category = m_category();
bindId = category.createBindId(); bindId = category.createBindId();
category.tick('n', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...); category.tick('n', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...);
} }
return {std::move(name), bindId, m_category}; return {PrivateTag{}, std::move(name), bindId, m_category};
} }
template<typename... Arguments> template<typename... Arguments>
@@ -1072,9 +1072,9 @@ public:
std::size_t id = 0; std::size_t id = 0;
if (m_bindId) { if (m_bindId) {
auto category = m_category(); auto &category = m_category();
id = category.createId(); id = category.createId();
category->begin('b', id, name, m_bindId, IsFlow::In, std::forward<Arguments>(arguments)...); category.begin('b', id, name, m_bindId, IsFlow::In, std::forward<Arguments>(arguments)...);
} }
return {std::move(name), id, m_category}; return {std::move(name), id, m_category};
@@ -1088,10 +1088,10 @@ public:
std::size_t bindId = 0; std::size_t bindId = 0;
if (m_bindId) { if (m_bindId) {
auto category = m_category(); auto &category = m_category();
id = category.createId(); id = category.createId();
bindId = category.createBindId(); bindId = category.createBindId();
category->begin('b', id, name, bindId, IsFlow::InOut, std::forward<Arguments>(arguments)...); category.begin('b', id, name, bindId, IsFlow::InOut, std::forward<Arguments>(arguments)...);
} }
return {std::piecewise_construct, return {std::piecewise_construct,
@@ -1232,6 +1232,9 @@ public:
m_bindIdCounter = m_globalBindIdCounter += 1ULL << 32; m_bindIdCounter = m_globalBindIdCounter += 1ULL << 32;
} }
Category(const Category &) = delete;
Category &operator=(const Category &) = delete;
template<typename... Arguments> template<typename... Arguments>
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType traceName, [[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType traceName,
Arguments &&...arguments) Arguments &&...arguments)