core: set thread name for tracy (#4076)
This commit is contained in:
@@ -917,6 +917,7 @@ list(APPEND SRC_FILES
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/i18n.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/i18n.hpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/identity.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/instrumentation.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/interpolate.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/intersection_tests.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/intersection_tests.hpp
|
||||
|
||||
@@ -549,6 +549,7 @@ MLN_CORE_SOURCE = [
|
||||
"src/mbgl/util/i18n.cpp",
|
||||
"src/mbgl/util/i18n.hpp",
|
||||
"src/mbgl/util/identity.cpp",
|
||||
"src/mbgl/util/instrumentation.cpp",
|
||||
"src/mbgl/util/interpolate.cpp",
|
||||
"src/mbgl/util/intersection_tests.cpp",
|
||||
"src/mbgl/util/intersection_tests.hpp",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef MLN_TRACY_ENABLE
|
||||
|
||||
#include <tracy/Tracy.hpp>
|
||||
@@ -128,3 +130,7 @@ constexpr const char* tracyConstMemoryLabel = "Constant Buffer Memory";
|
||||
#define MLN_TRACE_ZONE(label) ((void)0)
|
||||
|
||||
#endif // MLN_TRACY_ENABLE
|
||||
|
||||
namespace mbgl::instrumentation {
|
||||
void setThreadName(const std::string& name);
|
||||
};
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
#include <mbgl/util/instrumentation.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
@@ -51,6 +50,8 @@ public:
|
||||
runningPromise = std::move(running_),
|
||||
prioritySetter = std::move(prioritySetter_)]() mutable {
|
||||
platform::setCurrentThreadName(name);
|
||||
instrumentation::setThreadName(name);
|
||||
|
||||
if (prioritySetter) prioritySetter();
|
||||
platform::attachThread();
|
||||
|
||||
|
||||
11
src/mbgl/util/instrumentation.cpp
Normal file
11
src/mbgl/util/instrumentation.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <mbgl/util/instrumentation.hpp>
|
||||
|
||||
namespace mbgl::instrumentation {
|
||||
|
||||
void setThreadName([[maybe_unused]] const std::string &name) {
|
||||
#ifdef MLN_TRACY_ENABLE
|
||||
tracy::SetThreadName(name.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
}; // namespace mbgl::instrumentation
|
||||
Reference in New Issue
Block a user