From 4a1a7937ae795b46c885fd3edf871fe8cbb2468e Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 15 Jul 2016 15:01:16 +0300 Subject: [core] Move set/get thread names to platform:: Android needs its own implementation. --- src/mbgl/platform/log.cpp | 2 +- src/mbgl/util/thread.hpp | 25 +------------------------ 2 files changed, 2 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/mbgl/platform/log.cpp b/src/mbgl/platform/log.cpp index 0f334ae3e7..b140485dd6 100644 --- a/src/mbgl/platform/log.cpp +++ b/src/mbgl/platform/log.cpp @@ -50,7 +50,7 @@ void Log::record(EventSeverity severity, Event event, int64_t code, const std::s std::stringstream logStream; - logStream << "{" << util::getCurrentThreadName() << "}"; + logStream << "{" << platform::getCurrentThreadName() << "}"; logStream << "[" << Enum::toString(event) << "]"; if (code >= 0) { diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp index 643d272b25..cd90e08049 100644 --- a/src/mbgl/util/thread.hpp +++ b/src/mbgl/util/thread.hpp @@ -86,29 +86,6 @@ private: RunLoop* loop = nullptr; }; -inline std::string getCurrentThreadName() { - char name[32] = "unknown"; -#if defined(__APPLE__) - pthread_getname_np(pthread_self(), name, sizeof(name)); -#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if __GLIBC_PREREQ(2, 12) - pthread_getname_np(pthread_self(), name, sizeof(name)); -#endif -#endif - return name; -} - -inline void setCurrentThreadName(const std::string& name) { -#if defined(__APPLE__) - pthread_setname_np(name.c_str()); -#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if __GLIBC_PREREQ(2, 12) - pthread_setname_np(pthread_self(), name.c_str()); -#endif -#endif - (void)name; -} - template template Thread::Thread(const ThreadContext& context, Args&&... args) { @@ -117,7 +94,7 @@ Thread::Thread(const ThreadContext& context, Args&&... args) { std::tuple params = std::forward_as_tuple(::std::forward(args)...); thread = std::thread([&] { - setCurrentThreadName(context.name); + platform::setCurrentThreadName(context.name); if (context.priority == ThreadPriority::Low) { platform::makeThreadLowPriority(); -- cgit v1.2.1