forked from qt-creator/qt-creator
Nanotrace: Add flows
Change-Id: If9c6642449a495f2fcc94f843b7fcd7bf2ab4548 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -31,19 +31,38 @@ bool hasId(char phase)
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Id>
|
||||
unsigned int getUnsignedIntegerHash(Id id)
|
||||
{
|
||||
return static_cast<unsigned int>(id & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
unsigned int getUnsignedIntegerHash(std::thread::id id)
|
||||
{
|
||||
return static_cast<unsigned int>(std::hash<std::thread::id>{}(id) & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
template<typename TraceEvent>
|
||||
void printEvent(std::ostream &out, const TraceEvent &event, qint64 processId, std::thread::id threadId)
|
||||
{
|
||||
out << R"({"ph":")" << event.type << R"(","name":")" << event.name << R"(","cat":")"
|
||||
<< event.category << R"(","ts":)"
|
||||
<< static_cast<double>(event.time.time_since_epoch().count()) / 1000 << R"(,"pid":)"
|
||||
<< processId << R"(,"tid":)" << threadId;
|
||||
<< getUnsignedIntegerHash(processId) << R"(,"tid":)" << getUnsignedIntegerHash(threadId);
|
||||
|
||||
if (event.type == 'X')
|
||||
out << R"(,"dur":)" << static_cast<double>(event.duration.count()) / 1000;
|
||||
|
||||
if (hasId(event.type))
|
||||
out << R"(,"id":")" << event.id << R"(")";
|
||||
out << R"(,"id":)" << event.id;
|
||||
|
||||
if (event.bindId) {
|
||||
out << R"(,"bind_id":)" << event.bindId;
|
||||
if (event.flow & IsFlow::Out)
|
||||
out << R"(,"flow_out":true)";
|
||||
if (event.flow & IsFlow::In)
|
||||
out << R"(,"flow_in":true)";
|
||||
}
|
||||
|
||||
if (event.arguments.size())
|
||||
out << R"(,"args":)" << event.arguments;
|
||||
@@ -58,8 +77,9 @@ void writeMetaEvent(TraceFile<Tracing::IsEnabled> *file, std::string_view key, s
|
||||
|
||||
if (out.is_open()) {
|
||||
file->out << R"({"name":")" << key << R"(","ph":"M", "pid":)"
|
||||
<< QCoreApplication::applicationPid() << R"(,"tid":)"
|
||||
<< std::this_thread::get_id() << R"(,"args":{"name":")" << value << R"("}})"
|
||||
<< getUnsignedIntegerHash(QCoreApplication::applicationPid()) << R"(,"tid":)"
|
||||
<< getUnsignedIntegerHash(std::this_thread::get_id()) << R"(,"args":{"name":")"
|
||||
<< value << R"("}})"
|
||||
<< ",\n";
|
||||
}
|
||||
}
|
||||
@@ -150,7 +170,7 @@ void flushInThread(EnabledEventQueue<TraceEvent> &eventQueue)
|
||||
eventQueue.file->processing = std::async(std::launch::async,
|
||||
flush,
|
||||
eventQueue.currentEvents.subspan(0, eventQueue.eventsIndex),
|
||||
std::this_thread::get_id());
|
||||
eventQueue.threadId);
|
||||
eventQueue.currentEvents = eventQueue.currentEvents.data() == eventQueue.eventsOne.data()
|
||||
? eventQueue.eventsTwo
|
||||
: eventQueue.eventsOne;
|
||||
@@ -182,6 +202,7 @@ EventQueue<TraceEvent, Tracing::IsEnabled>::EventQueue(EnabledTraceFile *file,
|
||||
, eventsOne{eventsOne}
|
||||
, eventsTwo{eventsTwo}
|
||||
, currentEvents{eventsOne}
|
||||
, threadId{std::this_thread::get_id()}
|
||||
{
|
||||
if (auto thread = QThread::currentThread()) {
|
||||
connection = QObject::connect(QCoreApplication::instance(),
|
||||
@@ -208,7 +229,7 @@ void EventQueue<TraceEvent, Tracing::IsEnabled>::flush()
|
||||
{
|
||||
std::lock_guard lock{mutex};
|
||||
if (isEnabled == IsEnabled::Yes && eventsIndex > 0) {
|
||||
flushEvents(currentEvents.subspan(0, eventsIndex), std::this_thread::get_id(), *this);
|
||||
flushEvents(currentEvents.subspan(0, eventsIndex), threadId, *this);
|
||||
eventsIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +259,14 @@ template<typename String, typename... Arguments>
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
enum class IsFlow : std::size_t { No = 0, Out = 1 << 0, In = 1 << 1, InOut = In | Out };
|
||||
|
||||
inline bool operator&(IsFlow first, IsFlow second)
|
||||
{
|
||||
return static_cast<std::underlying_type_t<IsFlow>>(first)
|
||||
& static_cast<std::underlying_type_t<IsFlow>>(second);
|
||||
}
|
||||
|
||||
template<typename String, typename ArgumentsString>
|
||||
struct TraceEvent
|
||||
{
|
||||
@@ -279,6 +287,8 @@ struct TraceEvent
|
||||
TimePoint time;
|
||||
Duration duration;
|
||||
std::size_t id = 0;
|
||||
std::size_t bindId : 62;
|
||||
IsFlow flow : 2;
|
||||
char type = ' ';
|
||||
};
|
||||
|
||||
@@ -391,6 +401,7 @@ public:
|
||||
IsEnabled isEnabled = IsEnabled::Yes;
|
||||
QMetaObject::Connection connection;
|
||||
std::mutex mutex;
|
||||
std::thread::id threadId;
|
||||
};
|
||||
|
||||
extern template class NANOTRACE_EXPORT EventQueue<StringViewTraceEvent, Tracing::IsEnabled>;
|
||||
@@ -478,6 +489,151 @@ public:
|
||||
static constexpr bool isActive() { return false; }
|
||||
};
|
||||
|
||||
template<typename Category, typename IsActive>
|
||||
class Tracer;
|
||||
|
||||
template<typename Category, Tracing isEnabled>
|
||||
class Token : public BasicDisabledToken
|
||||
{
|
||||
public:
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using FlowTokenType = typename Category::FlowTokenType;
|
||||
using AsynchronousTokenType = typename Category::AsynchronousTokenType;
|
||||
using TracerType = typename Category::TracerType;
|
||||
|
||||
Token() {}
|
||||
|
||||
~Token() {}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowTokenType> beginAsynchronousWithFlow(
|
||||
ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] TracerType beginDuration(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<TracerType, FlowTokenType> beginDurationWithFlow(ArgumentType,
|
||||
Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(ArgumentType, Arguments &&...)
|
||||
{}
|
||||
};
|
||||
|
||||
template<typename Category>
|
||||
class Token<Category, Tracing::IsEnabled> : public BasicEnabledToken
|
||||
|
||||
{
|
||||
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
||||
|
||||
Token(std::size_t id, CategoryFunctionPointer category)
|
||||
: m_id{id}
|
||||
, m_category{category}
|
||||
{}
|
||||
|
||||
using PrivateTag = typename Category::PrivateTag;
|
||||
|
||||
public:
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using FlowTokenType = typename Category::FlowTokenType;
|
||||
using AsynchronousTokenType = typename Category::AsynchronousTokenType;
|
||||
using TracerType = typename Category::TracerType;
|
||||
|
||||
Token(PrivateTag, std::size_t id, CategoryFunctionPointer category)
|
||||
: Token{id, category}
|
||||
{}
|
||||
|
||||
friend TracerType;
|
||||
friend AsynchronousTokenType;
|
||||
|
||||
~Token() {}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
if (m_id)
|
||||
m_category().begin('b', m_id, name, 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
|
||||
return {std::move(name), m_id, m_category};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowTokenType> beginAsynchronousWithFlow(
|
||||
ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
std::size_t bindId = 0;
|
||||
|
||||
if (m_id) {
|
||||
auto category = m_category();
|
||||
bindId = category.createBindId();
|
||||
category.begin('b', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(std::move(name), m_id, m_category),
|
||||
std::forward_as_tuple(std::move(name), bindId, m_category)};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] TracerType beginDuration(ArgumentType traceName, Arguments &&...arguments)
|
||||
{
|
||||
return {traceName, m_category, std::forward<Arguments>(arguments)...};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<TracerType, FlowTokenType> beginDurationWithFlow(ArgumentType traceName,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
std::size_t bindId = m_category().createBindId();
|
||||
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(PrivateTag{},
|
||||
bindId,
|
||||
IsFlow::Out,
|
||||
traceName,
|
||||
m_category,
|
||||
std::forward<Arguments>(arguments)...),
|
||||
std::forward_as_tuple(PrivateTag{}, traceName, bindId, m_category)};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
m_category().begin('i', 0, name, 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t m_id = 0;
|
||||
CategoryFunctionPointer m_category = nullptr;
|
||||
};
|
||||
template<typename TraceEvent, Tracing isEnabled>
|
||||
class Category;
|
||||
|
||||
template<Tracing isEnabled>
|
||||
using StringViewCategory = Category<StringViewTraceEvent, isEnabled>;
|
||||
template<Tracing isEnabled>
|
||||
using StringCategory = Category<StringTraceEvent, isEnabled>;
|
||||
template<Tracing isEnabled>
|
||||
using StringViewWithStringArgumentsCategory = Category<StringViewWithStringArgumentsTraceEvent, isEnabled>;
|
||||
|
||||
using DisabledToken = Token<StringViewCategory<Tracing::IsDisabled>, Tracing::IsDisabled>;
|
||||
|
||||
template<typename Category, Tracing isEnabled>
|
||||
class ObjectToken : public BasicDisabledToken
|
||||
{
|
||||
@@ -499,10 +655,12 @@ public:
|
||||
template<typename Category>
|
||||
class ObjectToken<Category, Tracing::IsEnabled> : public BasicEnabledToken
|
||||
{
|
||||
ObjectToken(std::string_view name, std::size_t id, Category &category)
|
||||
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
||||
|
||||
ObjectToken(std::string_view name, std::size_t id, CategoryFunctionPointer category)
|
||||
: m_name{name}
|
||||
, m_id{id}
|
||||
, m_category{&category}
|
||||
, m_category{category}
|
||||
{}
|
||||
|
||||
public:
|
||||
@@ -511,14 +669,12 @@ public:
|
||||
|
||||
friend Category;
|
||||
|
||||
ObjectToken() = default;
|
||||
|
||||
ObjectToken(const ObjectToken &other)
|
||||
: m_name{other.m_name}
|
||||
, m_category{other.m_category}
|
||||
{
|
||||
if (other.m_id)
|
||||
m_id = m_category->beginObject(m_name).m_id;
|
||||
m_id = m_category().beginObject(m_name).m_id;
|
||||
}
|
||||
|
||||
ObjectToken &operator=(const ObjectToken &other)
|
||||
@@ -553,7 +709,7 @@ public:
|
||||
~ObjectToken()
|
||||
{
|
||||
if (m_id)
|
||||
m_category->end('e', m_id, std::move(m_name));
|
||||
m_category().end('e', m_id, std::move(m_name));
|
||||
|
||||
m_id = 0;
|
||||
}
|
||||
@@ -561,14 +717,16 @@ public:
|
||||
template<typename... Arguments>
|
||||
void change(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
if (m_id)
|
||||
m_category->tick('n', m_id, std::move(name), std::forward<Arguments>(arguments)...);
|
||||
if (m_id) {
|
||||
m_category().tick(
|
||||
'n', m_id, std::move(name), 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
StringType m_name;
|
||||
std::size_t m_id = 0;
|
||||
Category *m_category = nullptr;
|
||||
CategoryFunctionPointer m_category = nullptr;
|
||||
};
|
||||
|
||||
template<typename Category, Tracing isEnabled>
|
||||
@@ -576,6 +734,8 @@ class AsynchronousToken : public BasicDisabledToken
|
||||
{
|
||||
public:
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using FlowTokenType = typename Category::FlowTokenType;
|
||||
using TokenType = typename Category::TokenType;
|
||||
|
||||
AsynchronousToken() {}
|
||||
|
||||
@@ -586,44 +746,71 @@ public:
|
||||
|
||||
~AsynchronousToken() {}
|
||||
|
||||
[[nodiscard]] AsynchronousToken create() { return {}; }
|
||||
[[nodiscard]] TokenType createToken() { return {}; }
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousToken begin(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return AsynchronousToken{};
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(Arguments &&...)
|
||||
[[nodiscard]] std::pair<AsynchronousToken, FlowTokenType> beginWithFlow(ArgumentType,
|
||||
Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(ArgumentType, Arguments &&...)
|
||||
{}
|
||||
|
||||
template<typename... Arguments>
|
||||
FlowTokenType tickWithFlow(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void end(Arguments &&...)
|
||||
{}
|
||||
};
|
||||
|
||||
using DisabledAsynchronousToken = AsynchronousToken<StringViewTraceEvent, Tracing::IsDisabled>;
|
||||
|
||||
template<typename TraceEvent, Tracing isEnabled>
|
||||
class Category;
|
||||
using DisabledAsynchronousToken = AsynchronousToken<StringViewCategory<Tracing::IsDisabled>,
|
||||
Tracing::IsDisabled>;
|
||||
|
||||
template<typename Category, Tracing isEnabled>
|
||||
class FlowToken;
|
||||
|
||||
template<typename Category>
|
||||
class AsynchronousToken<Category, Tracing::IsEnabled> : public BasicEnabledToken
|
||||
{
|
||||
AsynchronousToken(std::string_view name, std::size_t id, Category &category)
|
||||
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
||||
|
||||
AsynchronousToken(std::string_view name, std::size_t id, CategoryFunctionPointer category)
|
||||
: m_name{name}
|
||||
, m_id{id}
|
||||
, m_category{&category}
|
||||
, m_category{category}
|
||||
{}
|
||||
|
||||
using PrivateTag = typename Category::PrivateTag;
|
||||
|
||||
public:
|
||||
using StringType = typename Category::StringType;
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using FlowTokenType = typename Category::FlowTokenType;
|
||||
using TokenType = typename Category::TokenType;
|
||||
|
||||
friend Category;
|
||||
friend FlowTokenType;
|
||||
friend TokenType;
|
||||
|
||||
AsynchronousToken() = default;
|
||||
AsynchronousToken(PrivateTag, std::string_view name, std::size_t id, CategoryFunctionPointer category)
|
||||
: AsynchronousToken{name, id, category}
|
||||
{}
|
||||
|
||||
AsynchronousToken() {}
|
||||
|
||||
AsynchronousToken(const AsynchronousToken &) = delete;
|
||||
AsynchronousToken &operator=(const AsynchronousToken &) = delete;
|
||||
@@ -647,29 +834,62 @@ public:
|
||||
|
||||
~AsynchronousToken() { end(); }
|
||||
|
||||
[[nodiscard]] AsynchronousToken create() { return {{}, m_id, *m_category}; }
|
||||
[[nodiscard]] TokenType createToken() { return {m_id, m_category}; }
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousToken begin(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
if (m_id)
|
||||
m_category->begin('b', m_id, name, std::forward<Arguments>(arguments)...);
|
||||
m_category().begin('b', m_id, name, 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
|
||||
return AsynchronousToken{std::move(name), m_id, *m_category};
|
||||
return AsynchronousToken{std::move(name), m_id, m_category};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousToken, FlowTokenType> beginWithFlow(ArgumentType name,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
std::size_t bindId = 0;
|
||||
|
||||
if (m_id) {
|
||||
auto category = m_category();
|
||||
bindId = category.createBindId();
|
||||
category.begin('b', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(std::move(name), m_id, m_category),
|
||||
std::forward_as_tuple(PrivateTag{}, std::move(name), bindId, m_category)};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
if (m_id)
|
||||
m_category->tick('n', m_id, std::move(name), std::forward<Arguments>(arguments)...);
|
||||
if (m_id) {
|
||||
m_category().tick(
|
||||
'n', m_id, std::move(name), 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
FlowTokenType tickWithFlow(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
std::size_t bindId = 0;
|
||||
|
||||
if (m_id) {
|
||||
auto category = m_category();
|
||||
bindId = category.createBindId();
|
||||
category.tick('n', m_id, name, bindId, IsFlow::Out, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
return {std::move(name), bindId, m_category};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void end(Arguments &&...arguments)
|
||||
{
|
||||
if (m_id && m_name.size())
|
||||
m_category->end('e', m_id, std::move(m_name), std::forward<Arguments>(arguments)...);
|
||||
m_category().end('e', m_id, std::move(m_name), std::forward<Arguments>(arguments)...);
|
||||
|
||||
m_id = 0;
|
||||
}
|
||||
@@ -677,7 +897,174 @@ public:
|
||||
private:
|
||||
StringType m_name;
|
||||
std::size_t m_id = 0;
|
||||
Category *m_category = nullptr;
|
||||
CategoryFunctionPointer m_category = nullptr;
|
||||
};
|
||||
|
||||
template<typename Category, Tracing isEnabled>
|
||||
class FlowToken : public BasicDisabledToken
|
||||
{
|
||||
public:
|
||||
FlowToken() = default;
|
||||
using AsynchronousTokenType = typename Category::AsynchronousTokenType;
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using TracerType = typename Category::TracerType;
|
||||
using TokenType = typename Category::TokenType;
|
||||
|
||||
friend TracerType;
|
||||
friend AsynchronousTokenType;
|
||||
friend TokenType;
|
||||
friend Category;
|
||||
|
||||
FlowToken(const FlowToken &) = delete;
|
||||
FlowToken &operator=(const FlowToken &) = delete;
|
||||
FlowToken(FlowToken &&other) noexcept = default;
|
||||
FlowToken &operator=(FlowToken &&other) noexcept = default;
|
||||
|
||||
~FlowToken() {}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowToken> beginAsynchronousWithFlow(ArgumentType,
|
||||
Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void connectTo(const AsynchronousTokenType &, Arguments &&...)
|
||||
{}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] TracerType beginDuration(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<TracerType, FlowToken> beginDurationWithFlow(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return std::pair<TracerType, FlowToken>();
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(ArgumentType, Arguments &&...)
|
||||
{}
|
||||
};
|
||||
|
||||
template<typename Category>
|
||||
class FlowToken<Category, Tracing::IsEnabled> : public BasicDisabledToken
|
||||
{
|
||||
using PrivateTag = typename Category::PrivateTag;
|
||||
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
||||
|
||||
public:
|
||||
FlowToken() = default;
|
||||
|
||||
FlowToken(PrivateTag, std::string_view name, std::size_t bindId, CategoryFunctionPointer category)
|
||||
: m_name{name}
|
||||
, m_bindId{bindId}
|
||||
, m_category{category}
|
||||
{}
|
||||
|
||||
using StringType = typename Category::StringType;
|
||||
using AsynchronousTokenType = typename Category::AsynchronousTokenType;
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using TracerType = typename Category::TracerType;
|
||||
using TokenType = typename Category::TokenType;
|
||||
|
||||
friend AsynchronousTokenType;
|
||||
friend TokenType;
|
||||
friend TracerType;
|
||||
friend Category;
|
||||
|
||||
FlowToken(const FlowToken &) = delete;
|
||||
FlowToken &operator=(const FlowToken &) = delete;
|
||||
FlowToken(FlowToken &&other) noexcept = default;
|
||||
FlowToken &operator=(FlowToken &&other) noexcept = default;
|
||||
|
||||
~FlowToken() {}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
std::size_t id = 0;
|
||||
|
||||
if (m_bindId) {
|
||||
auto category = m_category();
|
||||
id = category.createId();
|
||||
category->begin('b', id, name, m_bindId, IsFlow::In, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
return {std::move(name), id, m_category};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowToken> beginAsynchronousWithFlow(
|
||||
ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
std::size_t id = 0;
|
||||
std::size_t bindId = 0;
|
||||
|
||||
if (m_bindId) {
|
||||
auto category = m_category();
|
||||
id = category.createId();
|
||||
bindId = category.createBindId();
|
||||
category->begin('b', id, name, bindId, IsFlow::InOut, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(PrivateTag{}, std::move(name), id, m_category),
|
||||
std::forward_as_tuple(PrivateTag{}, std::move(name), bindId, m_category)};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void connectTo(const AsynchronousTokenType &token, Arguments &&...arguments)
|
||||
{
|
||||
if (m_bindId && token.m_id) {
|
||||
m_category().begin('b',
|
||||
token.m_id,
|
||||
token.m_name,
|
||||
m_bindId,
|
||||
IsFlow::In,
|
||||
std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] TracerType beginDuration(ArgumentType traceName, Arguments &&...arguments)
|
||||
{
|
||||
return {m_bindId, IsFlow::In, traceName, m_category, std::forward<Arguments>(arguments)...};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<TracerType, FlowToken> beginDurationWithFlow(ArgumentType traceName,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(PrivateTag{},
|
||||
m_bindId,
|
||||
IsFlow::InOut,
|
||||
traceName,
|
||||
m_category,
|
||||
std::forward<Arguments>(arguments)...),
|
||||
std::forward_as_tuple(PrivateTag{}, traceName, m_bindId, m_category)};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
m_category().tick('i', 0, name, m_bindId, IsFlow::In, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
private:
|
||||
StringType m_name;
|
||||
std::size_t m_bindId = 0;
|
||||
CategoryFunctionPointer m_category = nullptr;
|
||||
};
|
||||
|
||||
template<typename TraceEvent, Tracing isEnabled>
|
||||
@@ -689,10 +1076,15 @@ public:
|
||||
using ArgumentsStringType = typename TraceEvent::ArgumentsStringType;
|
||||
using AsynchronousTokenType = AsynchronousToken<Category, Tracing::IsDisabled>;
|
||||
using ObjectTokenType = ObjectToken<Category, Tracing::IsDisabled>;
|
||||
using FlowTokenType = FlowToken<Category, Tracing::IsDisabled>;
|
||||
using TracerType = Tracer<Category, std::false_type>;
|
||||
using TokenType = Token<Category, Tracing::IsDisabled>;
|
||||
using CategoryFunctionPointer = Category &(*) ();
|
||||
|
||||
Category(ArgumentType, EventQueue<TraceEvent, Tracing::IsDisabled> &) {}
|
||||
Category(ArgumentType, EventQueue<TraceEvent, Tracing::IsDisabled> &, CategoryFunctionPointer)
|
||||
{}
|
||||
|
||||
Category(ArgumentType, EventQueue<TraceEvent, Tracing::IsEnabled> &) {}
|
||||
Category(ArgumentType, EventQueue<TraceEvent, Tracing::IsEnabled> &, CategoryFunctionPointer) {}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType, Arguments &&...)
|
||||
@@ -700,18 +1092,39 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowTokenType> beginAsynchronousWithFlow(
|
||||
ArgumentType, Arguments &&...)
|
||||
{}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] ObjectTokenType beginObject(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] TracerType beginDuration(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<TracerType, FlowTokenType> beginDurationWithFlow(ArgumentType,
|
||||
Arguments &&...)
|
||||
{
|
||||
return std::pair<TracerType, FlowTokenType>();
|
||||
}
|
||||
|
||||
static constexpr bool isActive() { return false; }
|
||||
};
|
||||
|
||||
template<typename TraceEvent>
|
||||
class Category<TraceEvent, Tracing::IsEnabled>
|
||||
{
|
||||
class PrivateTag
|
||||
{};
|
||||
|
||||
public:
|
||||
using IsActive = std::true_type;
|
||||
using ArgumentType = typename TraceEvent::ArgumentType;
|
||||
@@ -719,40 +1132,84 @@ public:
|
||||
using StringType = typename TraceEvent::StringType;
|
||||
using AsynchronousTokenType = AsynchronousToken<Category, Tracing::IsEnabled>;
|
||||
using ObjectTokenType = ObjectToken<Category, Tracing::IsEnabled>;
|
||||
using FlowTokenType = FlowToken<Category, Tracing::IsEnabled>;
|
||||
using TracerType = Tracer<Category, std::true_type>;
|
||||
using TokenType = Token<Category, Tracing::IsEnabled>;
|
||||
using CategoryFunctionPointer = Category &(*) ();
|
||||
|
||||
friend AsynchronousTokenType;
|
||||
friend ObjectTokenType;
|
||||
friend TokenType;
|
||||
friend FlowTokenType;
|
||||
friend TracerType;
|
||||
|
||||
template<typename EventQueue>
|
||||
Category(ArgumentType name, EventQueue &queue)
|
||||
Category(ArgumentType name, EventQueue &queue, CategoryFunctionPointer self)
|
||||
: m_name{std::move(name)}
|
||||
, m_eventQueue{queue}
|
||||
, m_self{self}
|
||||
{
|
||||
static_assert(std::is_same_v<typename EventQueue::IsActive, std::true_type>,
|
||||
"A active category is not possible with an inactive event queue!");
|
||||
idCounter = globalIdCounter += 1ULL << 32;
|
||||
m_idCounter = m_globalIdCounter += 1ULL << 32;
|
||||
m_bindIdCounter = m_globalBindIdCounter += 1ULL << 32;
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] AsynchronousTokenType beginAsynchronous(ArgumentType traceName,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
std::size_t id = ++idCounter;
|
||||
std::size_t id = createId();
|
||||
|
||||
begin('b', id, std::move(traceName), std::forward<Arguments>(arguments)...);
|
||||
begin('b', id, std::move(traceName), 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
|
||||
return {traceName, id, *this};
|
||||
return {traceName, id, m_self};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<AsynchronousTokenType, FlowTokenType> beginAsynchronousWithFlow(
|
||||
ArgumentType traceName, Arguments &&...arguments)
|
||||
{
|
||||
std::size_t id = createId();
|
||||
std::size_t bindId = createBindId();
|
||||
|
||||
begin('b', id, std::move(traceName), bindId, IsFlow::Out, std::forward<Arguments>(arguments)...);
|
||||
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(PrivateTag{}, traceName, id, m_self),
|
||||
std::forward_as_tuple(PrivateTag{}, traceName, bindId, m_self)};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] ObjectTokenType beginObject(ArgumentType traceName, Arguments &&...arguments)
|
||||
{
|
||||
std::size_t id = ++idCounter;
|
||||
std::size_t id = createId();
|
||||
|
||||
if (id)
|
||||
begin('b', id, std::move(traceName), std::forward<Arguments>(arguments)...);
|
||||
begin('b', id, std::move(traceName), 0, IsFlow::No, std::forward<Arguments>(arguments)...);
|
||||
|
||||
return {traceName, id, *this};
|
||||
return {traceName, id, m_self};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] TracerType beginDuration(ArgumentType traceName, Arguments &&...arguments)
|
||||
{
|
||||
return {traceName, m_self, std::forward<Arguments>(arguments)...};
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] std::pair<TracerType, FlowTokenType> beginDurationWithFlow(ArgumentType traceName,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
std::size_t bindId = createBindId();
|
||||
|
||||
return {std::piecewise_construct,
|
||||
std::forward_as_tuple(PrivateTag{},
|
||||
bindId,
|
||||
IsFlow::Out,
|
||||
traceName,
|
||||
m_self,
|
||||
std::forward<Arguments>(arguments)...),
|
||||
std::forward_as_tuple(PrivateTag{}, traceName, bindId, m_self)};
|
||||
}
|
||||
|
||||
EnabledEventQueue<TraceEvent> &eventQueue() const { return m_eventQueue; }
|
||||
@@ -761,12 +1218,21 @@ public:
|
||||
|
||||
static constexpr bool isActive() { return true; }
|
||||
|
||||
std::size_t createBindId() { return ++m_bindIdCounter; }
|
||||
|
||||
std::size_t createId() { return ++m_idCounter; }
|
||||
|
||||
public:
|
||||
IsEnabled isEnabled = IsEnabled::Yes;
|
||||
|
||||
private:
|
||||
template<typename... Arguments>
|
||||
void begin(char type, std::size_t id, StringType traceName, Arguments &&...arguments)
|
||||
void begin(char type,
|
||||
std::size_t id,
|
||||
StringType traceName,
|
||||
std::size_t bindId,
|
||||
IsFlow flow,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
if (isEnabled == IsEnabled::No)
|
||||
return;
|
||||
@@ -777,12 +1243,19 @@ private:
|
||||
traceEvent.category = m_name;
|
||||
traceEvent.type = type;
|
||||
traceEvent.id = id;
|
||||
traceEvent.bindId = bindId;
|
||||
traceEvent.flow = flow;
|
||||
Internal::appendArguments(traceEvent.arguments, std::forward<Arguments>(arguments)...);
|
||||
traceEvent.time = Clock::now();
|
||||
}
|
||||
|
||||
template<typename... Arguments>
|
||||
void tick(char type, std::size_t id, StringType traceName, Arguments &&...arguments)
|
||||
void tick(char type,
|
||||
std::size_t id,
|
||||
StringType traceName,
|
||||
std::size_t bindId,
|
||||
IsFlow flow,
|
||||
Arguments &&...arguments)
|
||||
{
|
||||
if (isEnabled == IsEnabled::No)
|
||||
return;
|
||||
@@ -796,6 +1269,8 @@ private:
|
||||
traceEvent.time = time;
|
||||
traceEvent.type = type;
|
||||
traceEvent.id = id;
|
||||
traceEvent.bindId = bindId;
|
||||
traceEvent.flow = flow;
|
||||
Internal::appendArguments(traceEvent.arguments, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
@@ -814,14 +1289,19 @@ private:
|
||||
traceEvent.time = time;
|
||||
traceEvent.type = type;
|
||||
traceEvent.id = id;
|
||||
traceEvent.bindId = 0;
|
||||
traceEvent.flow = IsFlow::No;
|
||||
Internal::appendArguments(traceEvent.arguments, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
private:
|
||||
StringType m_name;
|
||||
EnabledEventQueue<TraceEvent> &m_eventQueue;
|
||||
inline static std::atomic<std::size_t> globalIdCounter;
|
||||
std::size_t idCounter;
|
||||
inline static std::atomic<std::size_t> m_globalIdCounter;
|
||||
std::size_t m_idCounter;
|
||||
inline static std::atomic<std::size_t> m_globalBindIdCounter;
|
||||
std::size_t m_bindIdCounter;
|
||||
CategoryFunctionPointer m_self;
|
||||
};
|
||||
|
||||
template<Tracing isEnabled>
|
||||
@@ -835,7 +1315,14 @@ template<typename Category, typename IsActive>
|
||||
class Tracer
|
||||
{
|
||||
public:
|
||||
Tracer() = default;
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using TokenType = typename Category::TokenType;
|
||||
using FlowTokenType = typename Category::FlowTokenType;
|
||||
|
||||
friend TokenType;
|
||||
friend FlowTokenType;
|
||||
friend Category;
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] Tracer(ArgumentType, Category &, Arguments &&...)
|
||||
@@ -845,6 +1332,17 @@ public:
|
||||
Tracer &operator=(const Tracer &) = delete;
|
||||
Tracer(Tracer &&other) noexcept = default;
|
||||
Tracer &operator=(Tracer &&other) noexcept = delete;
|
||||
|
||||
TokenType createToken() { return {}; }
|
||||
|
||||
template<typename... Arguments>
|
||||
Tracer beginDuration(ArgumentType, Arguments &&...)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void end() {}
|
||||
|
||||
~Tracer() {}
|
||||
};
|
||||
|
||||
@@ -854,14 +1352,50 @@ class Tracer<Category, std::true_type>
|
||||
using ArgumentType = typename Category::ArgumentType;
|
||||
using StringType = typename Category::StringType;
|
||||
using ArgumentsStringType = typename Category::ArgumentsStringType;
|
||||
using TokenType = typename Category::TokenType;
|
||||
using FlowTokenType = typename Category::FlowTokenType;
|
||||
using PrivateTag = typename Category::PrivateTag;
|
||||
using CategoryFunctionPointer = typename Category::CategoryFunctionPointer;
|
||||
|
||||
friend FlowTokenType;
|
||||
friend TokenType;
|
||||
friend Category;
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] Tracer(std::size_t bindId,
|
||||
IsFlow flow,
|
||||
ArgumentType name,
|
||||
CategoryFunctionPointer category,
|
||||
Arguments &&...arguments)
|
||||
: m_name{name}
|
||||
, m_bindId{bindId}
|
||||
, flow{flow}
|
||||
, m_category{category}
|
||||
{
|
||||
if (category().isEnabled == IsEnabled::Yes) {
|
||||
Internal::appendArguments<ArgumentsStringType>(m_arguments,
|
||||
std::forward<Arguments>(arguments)...);
|
||||
m_start = Clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] Tracer(ArgumentType name, Category &category, Arguments &&...arguments)
|
||||
[[nodiscard]] Tracer(PrivateTag,
|
||||
std::size_t bindId,
|
||||
IsFlow flow,
|
||||
ArgumentType name,
|
||||
CategoryFunctionPointer category,
|
||||
Arguments &&...arguments)
|
||||
: Tracer{bindId, flow, std::move(name), category, std::forward<Arguments>(arguments)...}
|
||||
{}
|
||||
|
||||
template<typename... Arguments>
|
||||
[[nodiscard]] Tracer(ArgumentType name, CategoryFunctionPointer category, Arguments &&...arguments)
|
||||
: m_name{name}
|
||||
, m_category{category}
|
||||
{
|
||||
if (category.isEnabled == IsEnabled::Yes) {
|
||||
if (category().isEnabled == IsEnabled::Yes) {
|
||||
Internal::appendArguments<ArgumentsStringType>(m_arguments,
|
||||
std::forward<Arguments>(arguments)...);
|
||||
m_start = Clock::now();
|
||||
@@ -872,17 +1406,38 @@ public:
|
||||
Tracer &operator=(const Tracer &) = delete;
|
||||
Tracer(Tracer &&other) noexcept = delete;
|
||||
Tracer &operator=(Tracer &&other) noexcept = delete;
|
||||
~Tracer()
|
||||
|
||||
TokenType createToken() { return {0, m_category}; }
|
||||
|
||||
~Tracer() { sendTrace(); }
|
||||
|
||||
template<typename... Arguments>
|
||||
Tracer beginDuration(ArgumentType name, Arguments &&...arguments)
|
||||
{
|
||||
if constexpr (tracingStatus() == Tracing::IsEnabled) {
|
||||
if (m_category.isEnabled == IsEnabled::Yes) {
|
||||
return {std::move(name), m_category, std::forward<Arguments>(arguments)...};
|
||||
}
|
||||
|
||||
void end()
|
||||
{
|
||||
sendTrace();
|
||||
m_name = {};
|
||||
}
|
||||
|
||||
private:
|
||||
void sendTrace()
|
||||
{
|
||||
if (m_name.size()) {
|
||||
auto category = m_category();
|
||||
if (category.isEnabled == IsEnabled::Yes) {
|
||||
auto duration = Clock::now() - m_start;
|
||||
auto &traceEvent = getTraceEvent(m_category.eventQueue());
|
||||
auto &traceEvent = getTraceEvent(category.eventQueue());
|
||||
traceEvent.name = m_name;
|
||||
traceEvent.category = m_category.name();
|
||||
traceEvent.category = category.name();
|
||||
traceEvent.arguments = m_arguments;
|
||||
traceEvent.time = m_start;
|
||||
traceEvent.duration = duration;
|
||||
traceEvent.bindId = m_bindId;
|
||||
traceEvent.flow = flow;
|
||||
traceEvent.type = 'X';
|
||||
}
|
||||
}
|
||||
@@ -892,7 +1447,9 @@ private:
|
||||
TimePoint m_start;
|
||||
StringType m_name;
|
||||
StringType m_arguments;
|
||||
Category &m_category;
|
||||
std::size_t m_bindId;
|
||||
IsFlow flow;
|
||||
CategoryFunctionPointer m_category;
|
||||
};
|
||||
|
||||
template<typename Category, typename... Arguments>
|
||||
|
||||
@@ -35,11 +35,18 @@ thread_local NanotraceHR::EventQueueData<NanotraceHR::StringViewTraceEvent, 1000
|
||||
eventQueueData(traceFile);
|
||||
thread_local NanotraceHR::EventQueue eventQueue = eventQueueData.createEventQueue();
|
||||
|
||||
thread_local NanotraceHR::StringViewCategory<sqliteTracingStatus()> sqliteLowLevelCategory{
|
||||
"sqlite low level"_t, eventQueue};
|
||||
NanotraceHR::StringViewCategory<sqliteTracingStatus()> &sqliteLowLevelCategory();
|
||||
|
||||
thread_local NanotraceHR::StringViewCategory<sqliteTracingStatus()> sqliteLowLevelCategory_{
|
||||
"sqlite low level"_t, eventQueue, sqliteLowLevelCategory};
|
||||
|
||||
NanotraceHR::StringViewCategory<sqliteTracingStatus()> &sqliteLowLevelCategory()
|
||||
{
|
||||
return sqliteLowLevelCategory_;
|
||||
}
|
||||
|
||||
thread_local NanotraceHR::StringViewCategory<sqliteTracingStatus()> sqliteHighLevelCategory_{
|
||||
"sqlite high level"_t, eventQueue};
|
||||
"sqlite high level"_t, eventQueue, sqliteHighLevelCategory};
|
||||
} // namespace
|
||||
|
||||
NanotraceHR::StringViewCategory<sqliteTracingStatus()> &sqliteHighLevelCategory()
|
||||
@@ -101,14 +108,14 @@ void BaseStatement::waitForUnlockNotify() const
|
||||
|
||||
void BaseStatement::reset() const noexcept
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"reset"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"reset"_t, sqliteLowLevelCategory()};
|
||||
|
||||
sqlite3_reset(m_compiledStatement.get());
|
||||
}
|
||||
|
||||
bool BaseStatement::next() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"next"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"next"_t, sqliteLowLevelCategory()};
|
||||
int resultCode;
|
||||
|
||||
do {
|
||||
@@ -135,7 +142,7 @@ void BaseStatement::step() const
|
||||
|
||||
void BaseStatement::bindNull(int index)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind null"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind null"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_bind_null(m_compiledStatement.get(), index);
|
||||
if (resultCode != SQLITE_OK)
|
||||
@@ -149,7 +156,7 @@ void BaseStatement::bind(int index, NullValue)
|
||||
|
||||
void BaseStatement::bind(int index, int value)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind int"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind int"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_bind_int(m_compiledStatement.get(), index, value);
|
||||
if (resultCode != SQLITE_OK)
|
||||
@@ -158,7 +165,7 @@ void BaseStatement::bind(int index, int value)
|
||||
|
||||
void BaseStatement::bind(int index, long long value)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind long long"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind long long"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_bind_int64(m_compiledStatement.get(), index, value);
|
||||
if (resultCode != SQLITE_OK)
|
||||
@@ -167,7 +174,7 @@ void BaseStatement::bind(int index, long long value)
|
||||
|
||||
void BaseStatement::bind(int index, double value)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind double"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind double"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_bind_double(m_compiledStatement.get(), index, value);
|
||||
if (resultCode != SQLITE_OK)
|
||||
@@ -176,7 +183,7 @@ void BaseStatement::bind(int index, double value)
|
||||
|
||||
void BaseStatement::bind(int index, void *pointer)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind pointer"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind pointer"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_bind_pointer(m_compiledStatement.get(), index, pointer, "carray", nullptr);
|
||||
if (resultCode != SQLITE_OK)
|
||||
@@ -185,7 +192,7 @@ void BaseStatement::bind(int index, void *pointer)
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<const int> values)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind int span"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind int span"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
@@ -199,7 +206,7 @@ void BaseStatement::bind(int index, Utils::span<const int> values)
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<const long long> values)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind long long span"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind long long span"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
@@ -213,7 +220,7 @@ void BaseStatement::bind(int index, Utils::span<const long long> values)
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<const double> values)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind double span"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind double span"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
@@ -227,7 +234,7 @@ void BaseStatement::bind(int index, Utils::span<const double> values)
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<const char *> values)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind const char* span"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind const char* span"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
@@ -241,7 +248,7 @@ void BaseStatement::bind(int index, Utils::span<const char *> values)
|
||||
|
||||
void BaseStatement::bind(int index, Utils::SmallStringView text)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind string"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind string"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = sqlite3_bind_text(m_compiledStatement.get(),
|
||||
index,
|
||||
@@ -254,7 +261,7 @@ void BaseStatement::bind(int index, Utils::SmallStringView text)
|
||||
|
||||
void BaseStatement::bind(int index, BlobView blobView)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind blob"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind blob"_t, sqliteLowLevelCategory()};
|
||||
|
||||
int resultCode = SQLITE_OK;
|
||||
|
||||
@@ -274,7 +281,7 @@ void BaseStatement::bind(int index, BlobView blobView)
|
||||
|
||||
void BaseStatement::bind(int index, const Value &value)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind value"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind value"_t, sqliteLowLevelCategory()};
|
||||
|
||||
switch (value.type()) {
|
||||
case ValueType::Integer:
|
||||
@@ -297,7 +304,7 @@ void BaseStatement::bind(int index, const Value &value)
|
||||
|
||||
void BaseStatement::bind(int index, ValueView value)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"bind value"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"bind value"_t, sqliteLowLevelCategory()};
|
||||
|
||||
switch (value.type()) {
|
||||
case ValueType::Integer:
|
||||
@@ -320,7 +327,7 @@ void BaseStatement::bind(int index, ValueView value)
|
||||
|
||||
void BaseStatement::prepare(Utils::SmallStringView sqlStatement)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"prepare"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"prepare"_t, sqliteLowLevelCategory()};
|
||||
|
||||
if (!m_database.isLocked())
|
||||
throw DatabaseIsNotLocked{};
|
||||
@@ -421,7 +428,7 @@ StringType convertToTextForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||
|
||||
Type BaseStatement::fetchType(int column) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch type"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch type"_t, sqliteLowLevelCategory()};
|
||||
|
||||
auto dataType = sqlite3_column_type(m_compiledStatement.get(), column);
|
||||
|
||||
@@ -443,7 +450,7 @@ Type BaseStatement::fetchType(int column) const
|
||||
|
||||
int BaseStatement::fetchIntValue(int column) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch int"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch int"_t, sqliteLowLevelCategory()};
|
||||
|
||||
return sqlite3_column_int(m_compiledStatement.get(), column);
|
||||
}
|
||||
@@ -467,7 +474,7 @@ long BaseStatement::fetchValue<long>(int column) const
|
||||
|
||||
long long BaseStatement::fetchLongLongValue(int column) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch long long"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch long long"_t, sqliteLowLevelCategory()};
|
||||
|
||||
return sqlite3_column_int64(m_compiledStatement.get(), column);
|
||||
}
|
||||
@@ -480,14 +487,14 @@ long long BaseStatement::fetchValue<long long>(int column) const
|
||||
|
||||
double BaseStatement::fetchDoubleValue(int column) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch double"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch double"_t, sqliteLowLevelCategory()};
|
||||
|
||||
return sqlite3_column_double(m_compiledStatement.get(), column);
|
||||
}
|
||||
|
||||
BlobView BaseStatement::fetchBlobValue(int column) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch blob"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch blob"_t, sqliteLowLevelCategory()};
|
||||
|
||||
return convertToBlobForColumn(m_compiledStatement.get(), column);
|
||||
}
|
||||
@@ -537,7 +544,7 @@ ValueView BaseStatement::fetchValueView(int column) const
|
||||
|
||||
void BaseStatement::Deleter::operator()(sqlite3_stmt *statement)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"finalize"_t, sqliteLowLevelCategory};
|
||||
NanotraceHR::Tracer tracer{"finalize"_t, sqliteLowLevelCategory()};
|
||||
|
||||
sqlite3_finalize(statement);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace NanotraceHR::Literals;
|
||||
namespace ImageCache {
|
||||
namespace {
|
||||
|
||||
thread_local Category category_{"image cache"_t, QmlDesigner::Tracing::eventQueue()};
|
||||
thread_local Category category_{"image cache"_t, QmlDesigner::Tracing::eventQueue(), category};
|
||||
} // namespace
|
||||
|
||||
Category &category()
|
||||
@@ -139,7 +139,7 @@ void AsynchronousImageCache::requestImage(Utils::SmallStringView name,
|
||||
{
|
||||
auto traceToken = ImageCache::category().beginAsynchronous(
|
||||
"request image in asynchornous image cache"_t);
|
||||
m_taskQueue.addTask(traceToken.create(),
|
||||
m_taskQueue.addTask(traceToken.createToken(),
|
||||
std::move(name),
|
||||
std::move(extraId),
|
||||
std::move(captureCallback),
|
||||
@@ -157,7 +157,7 @@ void AsynchronousImageCache::requestMidSizeImage(Utils::SmallStringView name,
|
||||
{
|
||||
auto traceToken = ImageCache::category().beginAsynchronous(
|
||||
"request mid size image in asynchornous image cache"_t);
|
||||
m_taskQueue.addTask(traceToken.create(),
|
||||
m_taskQueue.addTask(traceToken.createToken(),
|
||||
std::move(name),
|
||||
std::move(extraId),
|
||||
std::move(captureCallback),
|
||||
@@ -175,7 +175,7 @@ void AsynchronousImageCache::requestSmallImage(Utils::SmallStringView name,
|
||||
{
|
||||
auto traceToken = ImageCache::category().beginAsynchronous(
|
||||
"request small size image in asynchornous image cache"_t);
|
||||
m_taskQueue.addTask(traceToken.create(),
|
||||
m_taskQueue.addTask(traceToken.createToken(),
|
||||
std::move(name),
|
||||
std::move(extraId),
|
||||
std::move(captureCallback),
|
||||
|
||||
@@ -57,7 +57,8 @@ void AsynchronousImageFactory::request(Utils::SmallStringView name,
|
||||
extraId,
|
||||
std::move(auxiliaryData),
|
||||
std::move(capture),
|
||||
ImageCache::InternalAbortCallback{});
|
||||
ImageCache::InternalAbortCallback{},
|
||||
{});
|
||||
}
|
||||
|
||||
void AsynchronousImageFactory::clean()
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
const ImageCache::AuxiliaryData &auxiliaryData,
|
||||
CaptureCallback captureCallback,
|
||||
AbortCallback abortCallback,
|
||||
ImageCache::TraceToken traceToken = {})
|
||||
ImageCache::TraceToken traceToken)
|
||||
= 0;
|
||||
|
||||
virtual ImageTuple createImage(Utils::SmallStringView filePath,
|
||||
|
||||
@@ -111,35 +111,43 @@ void ImageCacheGenerator::waitForFinished()
|
||||
m_backgroundThread->wait();
|
||||
}
|
||||
|
||||
std::optional<ImageCacheGenerator::Task> ImageCacheGenerator::getTask()
|
||||
{
|
||||
{
|
||||
auto [lock, abort] = waitForEntries();
|
||||
|
||||
if (abort)
|
||||
return {};
|
||||
|
||||
std::optional<Task> task = std::move(m_tasks.front());
|
||||
|
||||
m_tasks.pop_front();
|
||||
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageCacheGenerator::startGeneration()
|
||||
{
|
||||
while (true) {
|
||||
Task task;
|
||||
auto task = getTask();
|
||||
|
||||
{
|
||||
auto [lock, abort] = waitForEntries();
|
||||
|
||||
if (abort)
|
||||
return;
|
||||
|
||||
task = std::move(m_tasks.front());
|
||||
|
||||
m_tasks.pop_front();
|
||||
}
|
||||
if (!task)
|
||||
return;
|
||||
|
||||
m_collector.start(
|
||||
task.filePath,
|
||||
task.extraId,
|
||||
std::move(task.auxiliaryData),
|
||||
task->filePath,
|
||||
task->extraId,
|
||||
std::move(task->auxiliaryData),
|
||||
[this,
|
||||
abortCallbacks = task.abortCallbacks,
|
||||
captureCallbacks = std::move(task.captureCallbacks),
|
||||
filePath = task.filePath,
|
||||
extraId = task.extraId,
|
||||
timeStamp = task.timeStamp](const QImage &image,
|
||||
const QImage &midSizeImage,
|
||||
const QImage &smallImage,
|
||||
ImageCache::TraceToken traceToken) {
|
||||
abortCallbacks = task->abortCallbacks,
|
||||
captureCallbacks = std::move(task->captureCallbacks),
|
||||
filePath = task->filePath,
|
||||
extraId = task->extraId,
|
||||
timeStamp = task->timeStamp](const QImage &image,
|
||||
const QImage &midSizeImage,
|
||||
const QImage &smallImage,
|
||||
ImageCache::TraceToken traceToken) {
|
||||
if (image.isNull() && midSizeImage.isNull() && smallImage.isNull())
|
||||
callCallbacks(abortCallbacks,
|
||||
ImageCache::AbortReason::Failed,
|
||||
@@ -158,16 +166,16 @@ void ImageCacheGenerator::startGeneration()
|
||||
smallImage);
|
||||
},
|
||||
[this,
|
||||
abortCallbacks = task.abortCallbacks,
|
||||
filePath = task.filePath,
|
||||
extraId = task.extraId,
|
||||
timeStamp = task.timeStamp](ImageCache::AbortReason abortReason,
|
||||
ImageCache::TraceToken traceToken) {
|
||||
abortCallbacks = task->abortCallbacks,
|
||||
filePath = task->filePath,
|
||||
extraId = task->extraId,
|
||||
timeStamp = task->timeStamp](ImageCache::AbortReason abortReason,
|
||||
ImageCache::TraceToken traceToken) {
|
||||
callCallbacks(abortCallbacks, abortReason, std::move(traceToken));
|
||||
if (abortReason != ImageCache::AbortReason::Abort)
|
||||
m_storage.storeImage(createId(filePath, extraId), timeStamp, {}, {}, {});
|
||||
},
|
||||
std::move(task.traceToken));
|
||||
std::move(task->traceToken));
|
||||
|
||||
std::lock_guard lock{m_mutex};
|
||||
if (m_tasks.empty())
|
||||
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
};
|
||||
|
||||
void startGeneration();
|
||||
std::optional<Task> getTask();
|
||||
void ensureThreadIsRunning();
|
||||
[[nodiscard]] std::tuple<std::unique_lock<std::mutex>, bool> waitForEntries();
|
||||
void stopThread();
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
ImageCache::CaptureImageWithScaledImagesCallback &&captureCallback,
|
||||
ImageCache::InternalAbortCallback &&abortCallback,
|
||||
ImageCache::AuxiliaryData &&auxiliaryData,
|
||||
ImageCache::TraceToken = {})
|
||||
ImageCache::TraceToken)
|
||||
= 0;
|
||||
|
||||
virtual void clean() = 0;
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
const ImageCache::AuxiliaryData &auxiliaryData,
|
||||
CaptureCallback captureCallback,
|
||||
AbortCallback abortCallback,
|
||||
ImageCache::TraceToken traceToken = {}) override;
|
||||
ImageCache::TraceToken traceToken) override;
|
||||
|
||||
ImageTuple createImage(Utils::SmallStringView filePath,
|
||||
Utils::SmallStringView state,
|
||||
|
||||
@@ -26,8 +26,7 @@ public:
|
||||
~TaskQueue() { destroy(); }
|
||||
|
||||
template<typename TraceEvent, NanotraceHR::Tracing isEnabled, typename... Arguments>
|
||||
void addTask(NanotraceHR::AsynchronousToken<TraceEvent, isEnabled> traceToken,
|
||||
Arguments &&...arguments)
|
||||
void addTask(NanotraceHR::Token<TraceEvent, isEnabled> traceToken, Arguments &&...arguments)
|
||||
{
|
||||
{
|
||||
std::unique_lock lock{m_mutex};
|
||||
@@ -42,7 +41,7 @@ public:
|
||||
template<typename... Arguments>
|
||||
void addTask(Arguments &&...arguments)
|
||||
{
|
||||
addTask(NanotraceHR::DisabledAsynchronousToken{}, std::forward<Arguments>(arguments)...);
|
||||
addTask(NanotraceHR::DisabledToken{}, std::forward<Arguments>(arguments)...);
|
||||
}
|
||||
|
||||
void clean()
|
||||
@@ -95,8 +94,8 @@ private:
|
||||
return {std::move(task)};
|
||||
}
|
||||
|
||||
template<typename TraceTokend>
|
||||
void ensureThreadIsRunning(TraceTokend traceToken)
|
||||
template<typename TraceToken>
|
||||
void ensureThreadIsRunning(TraceToken traceToken)
|
||||
{
|
||||
using namespace NanotraceHR::Literals;
|
||||
|
||||
@@ -108,7 +107,7 @@ private:
|
||||
|
||||
m_sleeping = false;
|
||||
|
||||
auto threadCreateToken = traceToken.begin("thread is created in the task queue"_t);
|
||||
auto threadCreateToken = traceToken.beginDuration("thread is created in the task queue"_t);
|
||||
m_backgroundThread = std::thread{[this](auto traceToken) {
|
||||
traceToken.tick("thread is ready"_t);
|
||||
while (true) {
|
||||
|
||||
@@ -9,8 +9,16 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
thread_local NanotraceHR::StringViewCategory<projectStorageTracingStatus()> projectStorageCategory{
|
||||
"project storage"_t, Tracing::eventQueue()};
|
||||
namespace {
|
||||
|
||||
thread_local NanotraceHR::StringViewCategory<projectStorageTracingStatus()> projectStorageCategory_{
|
||||
"project storage"_t, Tracing::eventQueue(), projectStorageCategory};
|
||||
}
|
||||
|
||||
NanotraceHR::StringViewCategory<projectStorageTracingStatus()> &projectStorageCategory()
|
||||
{
|
||||
return projectStorageCategory_;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ constexpr NanotraceHR::Tracing projectStorageTracingStatus()
|
||||
#endif
|
||||
}
|
||||
|
||||
extern thread_local NanotraceHR::StringViewCategory<projectStorageTracingStatus()> projectStorageCategory;
|
||||
NanotraceHR::StringViewCategory<projectStorageTracingStatus()> &projectStorageCategory();
|
||||
|
||||
template<typename Database>
|
||||
class ProjectStorage final : public ProjectStorageInterface
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
, exclusiveTransaction{database}
|
||||
, initializer{database, isInitialized}
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"initialize"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"initialize"_t, projectStorageCategory()};
|
||||
|
||||
exclusiveTransaction.commit();
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
void synchronize(Storage::Synchronization::SynchronizationPackage package) override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize"_t, projectStorageCategory()};
|
||||
|
||||
TypeIds deletedTypeIds;
|
||||
Sqlite::withImmediateTransaction(database, [&] {
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
|
||||
void synchronizeDocumentImports(Storage::Imports imports, SourceId sourceId) override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize document imports"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize document imports"_t, projectStorageCategory()};
|
||||
|
||||
Sqlite::withImmediateTransaction(database, [&] {
|
||||
synchronizeDocumentImports(imports,
|
||||
@@ -153,14 +153,14 @@ public:
|
||||
|
||||
ModuleId moduleId(Utils::SmallStringView moduleName) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get module id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get module id"_t, projectStorageCategory()};
|
||||
|
||||
return moduleCache.id(moduleName);
|
||||
}
|
||||
|
||||
Utils::SmallString moduleName(ModuleId moduleId) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get module name"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get module name"_t, projectStorageCategory()};
|
||||
|
||||
if (!moduleId)
|
||||
throw ModuleDoesNotExists{};
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
Utils::SmallStringView exportedTypeName,
|
||||
Storage::Version version) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type id by exported name"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type id by exported name"_t, projectStorageCategory()};
|
||||
|
||||
if (version.minor)
|
||||
return selectTypeIdByModuleIdAndExportedNameAndVersionStatement
|
||||
@@ -191,14 +191,14 @@ public:
|
||||
|
||||
TypeId typeId(ImportedTypeNameId typeNameId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type id by imported type name"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type id by imported type name"_t, projectStorageCategory()};
|
||||
|
||||
return Sqlite::withDeferredTransaction(database, [&] { return fetchTypeId(typeNameId); });
|
||||
}
|
||||
|
||||
QVarLengthArray<TypeId, 256> typeIds(ModuleId moduleId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type ids by module id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type ids by module id"_t, projectStorageCategory()};
|
||||
|
||||
return selectTypeIdsByModuleIdStatement
|
||||
.template valuesWithTransaction<QVarLengthArray<TypeId, 256>>(moduleId);
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
|
||||
Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get exported type names by type id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get exported type names by type id"_t, projectStorageCategory()};
|
||||
|
||||
return selectExportedTypesByTypeIdStatement
|
||||
.template valuesWithTransaction<Storage::Info::ExportedTypeName, 4>(typeId);
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
Storage::Info::ExportedTypeNames exportedTypeNames(TypeId typeId,
|
||||
SourceId sourceId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get exported type names by source id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get exported type names by source id"_t, projectStorageCategory()};
|
||||
|
||||
return selectExportedTypesByTypeIdAndSourceIdStatement
|
||||
.template valuesWithTransaction<Storage::Info::ExportedTypeName, 4>(typeId, sourceId);
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
|
||||
ImportId importId(const Storage::Import &import) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get import id by import"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get import id by import"_t, projectStorageCategory()};
|
||||
|
||||
return Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchImportId(import.sourceId, import);
|
||||
@@ -233,7 +233,8 @@ public:
|
||||
ImportedTypeNameId importedTypeNameId(ImportId importId,
|
||||
Utils::SmallStringView typeName) override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get imported type name id by import id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get imported type name id by import id"_t,
|
||||
projectStorageCategory()};
|
||||
|
||||
return Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchImportedTypeNameId(Storage::Synchronization::TypeNameKind::QualifiedExported,
|
||||
@@ -245,7 +246,8 @@ public:
|
||||
ImportedTypeNameId importedTypeNameId(SourceId sourceId,
|
||||
Utils::SmallStringView typeName) override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get imported type name id by source id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get imported type name id by source id"_t,
|
||||
projectStorageCategory()};
|
||||
|
||||
return Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchImportedTypeNameId(Storage::Synchronization::TypeNameKind::Exported,
|
||||
@@ -256,7 +258,7 @@ public:
|
||||
|
||||
QVarLengthArray<PropertyDeclarationId, 128> propertyDeclarationIds(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get property declaration ids"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get property declaration ids"_t, projectStorageCategory()};
|
||||
|
||||
return selectPropertyDeclarationIdsForTypeStatement
|
||||
.template valuesWithTransaction<QVarLengthArray<PropertyDeclarationId, 128>>(typeId);
|
||||
@@ -264,7 +266,7 @@ public:
|
||||
|
||||
QVarLengthArray<PropertyDeclarationId, 128> localPropertyDeclarationIds(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get local property declaration ids"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get local property declaration ids"_t, projectStorageCategory()};
|
||||
|
||||
return selectLocalPropertyDeclarationIdsForTypeStatement
|
||||
.template valuesWithTransaction<QVarLengthArray<PropertyDeclarationId, 128>>(typeId);
|
||||
@@ -273,7 +275,7 @@ public:
|
||||
PropertyDeclarationId propertyDeclarationId(TypeId typeId,
|
||||
Utils::SmallStringView propertyName) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get property declaration id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get property declaration id"_t, projectStorageCategory()};
|
||||
|
||||
return selectPropertyDeclarationIdForTypeAndPropertyNameStatement
|
||||
.template valueWithTransaction<PropertyDeclarationId>(typeId, propertyName);
|
||||
@@ -282,7 +284,7 @@ public:
|
||||
PropertyDeclarationId localPropertyDeclarationId(TypeId typeId,
|
||||
Utils::SmallStringView propertyName) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get local property declaration id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get local property declaration id"_t, projectStorageCategory()};
|
||||
|
||||
return selectLocalPropertyDeclarationIdForTypeAndPropertyNameStatement
|
||||
.template valueWithTransaction<PropertyDeclarationId>(typeId, propertyName);
|
||||
@@ -291,7 +293,7 @@ public:
|
||||
std::optional<Storage::Info::PropertyDeclaration> propertyDeclaration(
|
||||
PropertyDeclarationId propertyDeclarationId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get property declaration"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get property declaration"_t, projectStorageCategory()};
|
||||
|
||||
return selectPropertyDeclarationForPropertyDeclarationIdStatement
|
||||
.template optionalValueWithTransaction<Storage::Info::PropertyDeclaration>(
|
||||
@@ -300,7 +302,7 @@ public:
|
||||
|
||||
std::optional<Storage::Info::Type> type(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type"_t, projectStorageCategory()};
|
||||
|
||||
return selectInfoTypeByTypeIdStatement.template optionalValueWithTransaction<Storage::Info::Type>(
|
||||
typeId);
|
||||
@@ -308,14 +310,14 @@ public:
|
||||
|
||||
Utils::PathString typeIconPath(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type icon path"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type icon path"_t, projectStorageCategory()};
|
||||
|
||||
return selectTypeIconPathStatement.template valueWithTransaction<Utils::PathString>(typeId);
|
||||
}
|
||||
|
||||
Storage::Info::TypeHints typeHints(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type hints"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type hints"_t, projectStorageCategory()};
|
||||
|
||||
return selectTypeHintsStatement.template valuesWithTransaction<Storage::Info::TypeHints, 4>(
|
||||
typeId);
|
||||
@@ -323,7 +325,7 @@ public:
|
||||
|
||||
Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get item library entries by type id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get item library entries by type id"_t, projectStorageCategory()};
|
||||
|
||||
using Storage::Info::ItemLibraryProperties;
|
||||
Storage::Info::ItemLibraryEntries entries;
|
||||
@@ -352,7 +354,8 @@ public:
|
||||
|
||||
Storage::Info::ItemLibraryEntries itemLibraryEntries(SourceId sourceId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get item library entries by source id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get item library entries by source id"_t,
|
||||
projectStorageCategory()};
|
||||
|
||||
using Storage::Info::ItemLibraryProperties;
|
||||
Storage::Info::ItemLibraryEntries entries;
|
||||
@@ -381,7 +384,7 @@ public:
|
||||
|
||||
Storage::Info::ItemLibraryEntries allItemLibraryEntries() const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get all item library entries"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get all item library entries"_t, projectStorageCategory()};
|
||||
|
||||
using Storage::Info::ItemLibraryProperties;
|
||||
Storage::Info::ItemLibraryEntries entries;
|
||||
@@ -410,7 +413,7 @@ public:
|
||||
|
||||
std::vector<Utils::SmallString> signalDeclarationNames(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get signal names"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get signal names"_t, projectStorageCategory()};
|
||||
|
||||
return selectSignalDeclarationNamesForTypeStatement
|
||||
.template valuesWithTransaction<Utils::SmallString, 32>(typeId);
|
||||
@@ -418,7 +421,7 @@ public:
|
||||
|
||||
std::vector<Utils::SmallString> functionDeclarationNames(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get function names"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get function names"_t, projectStorageCategory()};
|
||||
|
||||
return selectFuncionDeclarationNamesForTypeStatement
|
||||
.template valuesWithTransaction<Utils::SmallString, 32>(typeId);
|
||||
@@ -426,7 +429,7 @@ public:
|
||||
|
||||
std::optional<Utils::SmallString> propertyName(PropertyDeclarationId propertyDeclarationId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get property name"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get property name"_t, projectStorageCategory()};
|
||||
|
||||
return selectPropertyNameStatement.template optionalValueWithTransaction<Utils::SmallString>(
|
||||
propertyDeclarationId);
|
||||
@@ -440,7 +443,7 @@ public:
|
||||
template<const char *moduleName, const char *typeName>
|
||||
TypeId commonTypeId() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get type id from common type cache"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get type id from common type cache"_t, projectStorageCategory()};
|
||||
|
||||
return commonTypeCache_.template typeId<moduleName, typeName>();
|
||||
}
|
||||
@@ -449,7 +452,7 @@ public:
|
||||
TypeId builtinTypeId() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get builtin type id from common type cache"_t,
|
||||
projectStorageCategory};
|
||||
projectStorageCategory()};
|
||||
|
||||
return commonTypeCache_.template builtinTypeId<BuiltinType>();
|
||||
}
|
||||
@@ -458,14 +461,14 @@ public:
|
||||
TypeId builtinTypeId() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get builtin type id from common type cache"_t,
|
||||
projectStorageCategory};
|
||||
projectStorageCategory()};
|
||||
|
||||
return commonTypeCache_.template builtinTypeId<builtinType>();
|
||||
}
|
||||
|
||||
TypeIds prototypeIds(TypeId type) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get prototypes"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get prototypes"_t, projectStorageCategory()};
|
||||
|
||||
return selectPrototypeIdsForTypeIdInOrderStatement.template valuesWithTransaction<TypeId, 16>(
|
||||
type);
|
||||
@@ -473,7 +476,7 @@ public:
|
||||
|
||||
TypeIds prototypeAndSelfIds(TypeId type) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get prototypes and self"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get prototypes and self"_t, projectStorageCategory()};
|
||||
|
||||
return selectPrototypeAndSelfIdsForTypeIdInOrderStatement
|
||||
.template valuesWithTransaction<TypeId, 16>(type);
|
||||
@@ -481,7 +484,7 @@ public:
|
||||
|
||||
TypeIds heirIds(TypeId typeId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"get heirs"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"get heirs"_t, projectStorageCategory()};
|
||||
|
||||
return selectHeirTypeIdsStatement.template valuesWithTransaction<TypeId, 64>(typeId);
|
||||
}
|
||||
@@ -489,7 +492,7 @@ public:
|
||||
template<typename... TypeIds>
|
||||
bool isBasedOn_(TypeId typeId, TypeIds... baseTypeIds) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"is based on"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"is based on"_t, projectStorageCategory()};
|
||||
|
||||
static_assert(((std::is_same_v<TypeId, TypeIds>) &&...), "Parameter must be a TypeId!");
|
||||
|
||||
@@ -550,7 +553,7 @@ public:
|
||||
|
||||
TypeId fetchTypeIdByExportedName(Utils::SmallStringView name) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"is based on"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"is based on"_t, projectStorageCategory()};
|
||||
|
||||
return selectTypeIdByExportedNameStatement.template valueWithTransaction<TypeId>(name);
|
||||
}
|
||||
@@ -612,7 +615,7 @@ public:
|
||||
|
||||
SourceContextId fetchSourceContextIdUnguarded(Utils::SmallStringView sourceContextPath)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source context id unguarded"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch source context id unguarded"_t, projectStorageCategory()};
|
||||
|
||||
auto sourceContextId = readSourceContextId(sourceContextPath);
|
||||
|
||||
@@ -621,7 +624,7 @@ public:
|
||||
|
||||
SourceContextId fetchSourceContextId(Utils::SmallStringView sourceContextPath)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source context id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch source context id"_t, projectStorageCategory()};
|
||||
|
||||
try {
|
||||
return Sqlite::withDeferredTransaction(database, [&] {
|
||||
@@ -634,7 +637,7 @@ public:
|
||||
|
||||
Utils::PathString fetchSourceContextPath(SourceContextId sourceContextId) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source context path"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch source context path"_t, projectStorageCategory()};
|
||||
|
||||
return Sqlite::withDeferredTransaction(database, [&] {
|
||||
auto optionalSourceContextPath = selectSourceContextPathFromSourceContextsBySourceContextIdStatement
|
||||
@@ -650,7 +653,7 @@ public:
|
||||
|
||||
auto fetchAllSourceContexts() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch all source contexts"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch all source contexts"_t, projectStorageCategory()};
|
||||
|
||||
return selectAllSourceContextsStatement
|
||||
.template valuesWithTransaction<Cache::SourceContext, 128>();
|
||||
@@ -658,7 +661,7 @@ public:
|
||||
|
||||
SourceId fetchSourceId(SourceContextId sourceContextId, Utils::SmallStringView sourceName)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch source id"_t, projectStorageCategory()};
|
||||
|
||||
return Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchSourceIdUnguarded(sourceContextId, sourceName);
|
||||
@@ -668,7 +671,7 @@ public:
|
||||
auto fetchSourceNameAndSourceContextId(SourceId sourceId) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source name and source context id"_t,
|
||||
projectStorageCategory};
|
||||
projectStorageCategory()};
|
||||
|
||||
auto value = selectSourceNameAndSourceContextIdFromSourcesBySourceIdStatement
|
||||
.template valueWithTransaction<Cache::SourceNameAndSourceContextId>(sourceId);
|
||||
@@ -689,7 +692,7 @@ public:
|
||||
|
||||
SourceContextId fetchSourceContextId(SourceId sourceId) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source context id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch source context id"_t, projectStorageCategory()};
|
||||
|
||||
auto sourceContextId = selectSourceContextIdFromSourcesBySourceIdStatement
|
||||
.template valueWithTransaction<SourceContextId>(sourceId);
|
||||
@@ -702,14 +705,14 @@ public:
|
||||
|
||||
auto fetchAllSources() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch all sources"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch all sources"_t, projectStorageCategory()};
|
||||
|
||||
return selectAllSourcesStatement.template valuesWithTransaction<Cache::Source, 1024>();
|
||||
}
|
||||
|
||||
SourceId fetchSourceIdUnguarded(SourceContextId sourceContextId, Utils::SmallStringView sourceName)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch source id unguarded"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch source id unguarded"_t, projectStorageCategory()};
|
||||
|
||||
auto sourceId = readSourceId(sourceContextId, sourceName);
|
||||
|
||||
@@ -721,14 +724,14 @@ public:
|
||||
|
||||
auto fetchAllFileStatuses() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch all file statuses"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch all file statuses"_t, projectStorageCategory()};
|
||||
|
||||
return selectAllFileStatusesStatement.template rangeWithTransaction<FileStatus>();
|
||||
}
|
||||
|
||||
FileStatus fetchFileStatus(SourceId sourceId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch file status"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch file status"_t, projectStorageCategory()};
|
||||
|
||||
return selectFileStatusesForSourceIdStatement.template valueWithTransaction<FileStatus>(
|
||||
sourceId);
|
||||
@@ -736,7 +739,7 @@ public:
|
||||
|
||||
std::optional<Storage::Synchronization::ProjectData> fetchProjectData(SourceId sourceId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch project data"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch project data"_t, projectStorageCategory()};
|
||||
|
||||
return selectProjectDataForSourceIdStatement
|
||||
.template optionalValueWithTransaction<Storage::Synchronization::ProjectData>(sourceId);
|
||||
@@ -744,7 +747,7 @@ public:
|
||||
|
||||
Storage::Synchronization::ProjectDatas fetchProjectDatas(SourceId projectSourceId) const override
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch project datas by source id"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch project datas by source id"_t, projectStorageCategory()};
|
||||
|
||||
return selectProjectDatasForSourceIdStatement
|
||||
.template valuesWithTransaction<Storage::Synchronization::ProjectData, 1024>(
|
||||
@@ -753,7 +756,7 @@ public:
|
||||
|
||||
Storage::Synchronization::ProjectDatas fetchProjectDatas(const SourceIds &projectSourceIds) const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch project datas by source ids"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch project datas by source ids"_t, projectStorageCategory()};
|
||||
|
||||
return selectProjectDatasForSourceIdsStatement
|
||||
.template valuesWithTransaction<Storage::Synchronization::ProjectData, 64>(
|
||||
@@ -776,7 +779,7 @@ public:
|
||||
|
||||
Storage::Imports fetchDocumentImports() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch document imports"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"fetch document imports"_t, projectStorageCategory()};
|
||||
|
||||
return selectAllDocumentImportForSourceIdStatement
|
||||
.template valuesWithTransaction<Storage::Imports>();
|
||||
@@ -1030,7 +1033,7 @@ private:
|
||||
void synchronizeTypeAnnotations(Storage::Synchronization::TypeAnnotations &typeAnnotations,
|
||||
const SourceIds &updatedTypeAnnotationSourceIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize type annotations"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize type annotations"_t, projectStorageCategory()};
|
||||
|
||||
using Storage::Synchronization::TypeAnnotation;
|
||||
|
||||
@@ -1099,7 +1102,7 @@ private:
|
||||
Prototypes &relinkableExtensions,
|
||||
const SourceIds &updatedSourceIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize types"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize types"_t, projectStorageCategory()};
|
||||
|
||||
Storage::Synchronization::ExportedTypes exportedTypes;
|
||||
exportedTypes.reserve(types.size() * 3);
|
||||
@@ -1156,7 +1159,7 @@ private:
|
||||
void synchronizeProjectDatas(Storage::Synchronization::ProjectDatas &projectDatas,
|
||||
const SourceIds &updatedProjectSourceIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize project datas"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize project datas"_t, projectStorageCategory()};
|
||||
|
||||
auto compareKey = [](auto &&first, auto &&second) {
|
||||
auto projectSourceIdDifference = first.projectSourceId - second.projectSourceId;
|
||||
@@ -1210,7 +1213,7 @@ private:
|
||||
|
||||
void synchronizeFileStatuses(FileStatuses &fileStatuses, const SourceIds &updatedSourceIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize file statuses"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize file statuses"_t, projectStorageCategory()};
|
||||
|
||||
auto compareKey = [](auto &&first, auto &&second) {
|
||||
return first.sourceId - second.sourceId;
|
||||
@@ -1257,7 +1260,7 @@ private:
|
||||
Storage::Synchronization::ModuleExportedImports &moduleExportedImports,
|
||||
const ModuleIds &updatedModuleIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize imports"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize imports"_t, projectStorageCategory()};
|
||||
|
||||
synchromizeModuleExportedImports(moduleExportedImports, updatedModuleIds);
|
||||
synchronizeDocumentImports(imports,
|
||||
@@ -1418,7 +1421,7 @@ private:
|
||||
void relinkAliasPropertyDeclarations(AliasPropertyDeclarations &aliasPropertyDeclarations,
|
||||
const TypeIds &deletedTypeIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"relink alias properties"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"relink alias properties"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(aliasPropertyDeclarations.begin(), aliasPropertyDeclarations.end());
|
||||
|
||||
@@ -1448,7 +1451,7 @@ private:
|
||||
void relinkPropertyDeclarations(PropertyDeclarations &relinkablePropertyDeclaration,
|
||||
const TypeIds &deletedTypeIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"relink properties"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"relink properties"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(relinkablePropertyDeclaration.begin(), relinkablePropertyDeclaration.end());
|
||||
|
||||
@@ -1474,7 +1477,7 @@ private:
|
||||
const TypeIds &deletedTypeIds,
|
||||
Callable updateStatement)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"relink prototypes"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"relink prototypes"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(relinkablePrototypes.begin(), relinkablePrototypes.end());
|
||||
|
||||
@@ -1504,7 +1507,7 @@ private:
|
||||
Prototypes &relinkableExtensions,
|
||||
TypeIds &deletedTypeIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"delete not updated types"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"delete not updated types"_t, projectStorageCategory()};
|
||||
|
||||
auto callback = [&](TypeId typeId) {
|
||||
deletedTypeIds.push_back(typeId);
|
||||
@@ -1528,7 +1531,7 @@ private:
|
||||
Prototypes &relinkableExtensions,
|
||||
TypeIds &deletedTypeIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"relink"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"relink"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(deletedTypeIds.begin(), deletedTypeIds.end());
|
||||
|
||||
@@ -1596,7 +1599,7 @@ private:
|
||||
void linkAliases(const AliasPropertyDeclarations &insertedAliasPropertyDeclarations,
|
||||
const AliasPropertyDeclarations &updatedAliasPropertyDeclarations)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"link aliases"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"link aliases"_t, projectStorageCategory()};
|
||||
|
||||
linkAliasPropertyDeclarationAliasIds(insertedAliasPropertyDeclarations);
|
||||
linkAliasPropertyDeclarationAliasIds(updatedAliasPropertyDeclarations);
|
||||
@@ -1615,7 +1618,7 @@ private:
|
||||
Prototypes &relinkablePrototypes,
|
||||
Prototypes &relinkableExtensions)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize exported types"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize exported types"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(exportedTypes.begin(), exportedTypes.end(), [](auto &&first, auto &&second) {
|
||||
if (first.moduleId < second.moduleId)
|
||||
@@ -1800,7 +1803,7 @@ private:
|
||||
AliasPropertyDeclarations &updatedAliasPropertyDeclarations,
|
||||
PropertyDeclarationIds &propertyDeclarationIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize property declaration"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize property declaration"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(propertyDeclarations.begin(),
|
||||
propertyDeclarations.end(),
|
||||
@@ -1918,7 +1921,8 @@ private:
|
||||
Storage::Synchronization::Types &types,
|
||||
AliasPropertyDeclarations &relinkableAliasPropertyDeclarations)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"reset removed alias properties to null"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"reset removed alias properties to null"_t,
|
||||
projectStorageCategory()};
|
||||
|
||||
PropertyDeclarationIds propertyDeclarationIds;
|
||||
propertyDeclarationIds.reserve(types.size());
|
||||
@@ -2117,7 +2121,8 @@ private:
|
||||
void synchronizePropertyEditorQmlPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
|
||||
SourceIds updatedPropertyEditorQmlPathsSourceIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize property editor qml paths"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize property editor qml paths"_t,
|
||||
projectStorageCategory()};
|
||||
|
||||
addTypeIdToPropertyEditorQmlPaths(paths);
|
||||
synchronizePropertyEditorPaths(paths, updatedPropertyEditorQmlPathsSourceIds);
|
||||
@@ -2126,7 +2131,7 @@ private:
|
||||
void synchronizeFunctionDeclarations(
|
||||
TypeId typeId, Storage::Synchronization::FunctionDeclarations &functionsDeclarations)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize function declaration"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize function declaration"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(functionsDeclarations.begin(),
|
||||
functionsDeclarations.end(),
|
||||
@@ -2185,7 +2190,7 @@ private:
|
||||
void synchronizeSignalDeclarations(TypeId typeId,
|
||||
Storage::Synchronization::SignalDeclarations &signalDeclarations)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize signal declaration"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize signal declaration"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(signalDeclarations.begin(), signalDeclarations.end(), [](auto &&first, auto &&second) {
|
||||
auto compare = Sqlite::compare(first.name, second.name);
|
||||
@@ -2261,7 +2266,7 @@ private:
|
||||
void synchronizeEnumerationDeclarations(
|
||||
TypeId typeId, Storage::Synchronization::EnumerationDeclarations &enumerationDeclarations)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize enumeation declaration"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize enumeation declaration"_t, projectStorageCategory()};
|
||||
|
||||
std::sort(enumerationDeclarations.begin(),
|
||||
enumerationDeclarations.end(),
|
||||
@@ -2335,7 +2340,7 @@ private:
|
||||
AliasPropertyDeclarations &updatedAliasPropertyDeclarations,
|
||||
PropertyDeclarationIds &propertyDeclarationIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize declaration per type"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize declaration per type"_t, projectStorageCategory()};
|
||||
|
||||
if (type.changeLevel == Storage::Synchronization::ChangeLevel::Minimal)
|
||||
return;
|
||||
@@ -2354,7 +2359,7 @@ private:
|
||||
template<typename Relinkable, typename Ids, typename Compare>
|
||||
void removeRelinkableEntries(std::vector<Relinkable> &relinkables, Ids &ids, Compare compare)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"remove relinkable entries"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"remove relinkable entries"_t, projectStorageCategory()};
|
||||
|
||||
std::vector<Relinkable> newRelinkables;
|
||||
newRelinkables.reserve(relinkables.size());
|
||||
@@ -2378,7 +2383,7 @@ private:
|
||||
AliasPropertyDeclarations &updatedAliasPropertyDeclarations,
|
||||
PropertyDeclarations &relinkablePropertyDeclarations)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize declaration"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize declaration"_t, projectStorageCategory()};
|
||||
|
||||
PropertyDeclarationIds propertyDeclarationIds;
|
||||
propertyDeclarationIds.reserve(types.size() * 10);
|
||||
@@ -2408,7 +2413,7 @@ private:
|
||||
|
||||
void syncDefaultProperties(Storage::Synchronization::Types &types)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize default properties"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize default properties"_t, projectStorageCategory()};
|
||||
|
||||
auto range = selectTypesWithDefaultPropertyStatement.template range<TypeWithDefaultPropertyView>();
|
||||
|
||||
@@ -2444,7 +2449,7 @@ private:
|
||||
|
||||
void resetDefaultPropertiesIfChanged(Storage::Synchronization::Types &types)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"reset changed default properties"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"reset changed default properties"_t, projectStorageCategory()};
|
||||
|
||||
auto range = selectTypesWithDefaultPropertyStatement.template range<TypeWithDefaultPropertyView>();
|
||||
|
||||
@@ -2544,7 +2549,7 @@ private:
|
||||
Prototypes &relinkablePrototypes,
|
||||
Prototypes &relinkableExtensions)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize prototypes"_t, projectStorageCategory};
|
||||
NanotraceHR::Tracer tracer{"synchronize prototypes"_t, projectStorageCategory()};
|
||||
|
||||
TypeIds typeIds;
|
||||
typeIds.reserve(types.size());
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ModelTracing {
|
||||
namespace {
|
||||
using namespace NanotraceHR::Literals;
|
||||
|
||||
thread_local Category category_{"model"_t, Tracing::stringViewEventWithStringArgumentsQueue_};
|
||||
thread_local Category category_{"model"_t, Tracing::stringViewEventWithStringArgumentsQueue_, category};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user