[core] Set names to threads on Linux

Makes debugging/profiling easier.
This commit is contained in:
Thiago Marcos P. Santos
2015-10-29 11:54:43 +02:00
parent d20bcb0795
commit 978da4224e
2 changed files with 4 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ namespace mbgl {
using namespace mapbox::sqlite;
SQLiteCache::SQLiteCache(const std::string& path_)
: thread(std::make_unique<util::Thread<Impl>>(util::ThreadContext{"SQLite Cache", util::ThreadType::Unknown, util::ThreadPriority::Low}, path_)) {
: thread(std::make_unique<util::Thread<Impl>>(util::ThreadContext{"SQLiteCache", util::ThreadType::Unknown, util::ThreadPriority::Low}, path_)) {
}
SQLiteCache::~SQLiteCache() = default;

View File

@@ -93,8 +93,10 @@ Thread<Object>::Thread(const ThreadContext& context, Args&&... args) {
std::tuple<Args...> params = std::forward_as_tuple(::std::forward<Args>(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) {