From 978da4224e20c01efb01efe95bbfe51a45c6087d Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 29 Oct 2015 11:54:43 +0200 Subject: [PATCH] [core] Set names to threads on Linux Makes debugging/profiling easier. --- platform/default/sqlite_cache.cpp | 2 +- src/mbgl/util/thread.hpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/default/sqlite_cache.cpp b/platform/default/sqlite_cache.cpp index e618c960c..dfb629054 100644 --- a/platform/default/sqlite_cache.cpp +++ b/platform/default/sqlite_cache.cpp @@ -16,7 +16,7 @@ namespace mbgl { using namespace mapbox::sqlite; SQLiteCache::SQLiteCache(const std::string& path_) - : thread(std::make_unique>(util::ThreadContext{"SQLite Cache", util::ThreadType::Unknown, util::ThreadPriority::Low}, path_)) { + : thread(std::make_unique>(util::ThreadContext{"SQLiteCache", util::ThreadType::Unknown, util::ThreadPriority::Low}, path_)) { } SQLiteCache::~SQLiteCache() = default; diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp index b0d17bd52..d7611254c 100644 --- a/src/mbgl/util/thread.hpp +++ b/src/mbgl/util/thread.hpp @@ -93,8 +93,10 @@ Thread::Thread(const ThreadContext& context, Args&&... args) { std::tuple params = std::forward_as_tuple(::std::forward(args)...); thread = std::thread([&] { - #ifdef __APPLE__ + #if defined( __APPLE__) pthread_setname_np(context.name.c_str()); + #elif defined(__linux__) + pthread_setname_np(pthread_self(), context.name.c_str()); #endif if (context.priority == ThreadPriority::Low) {