summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-07-15 15:01:16 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-07-16 10:38:42 +0300
commit4a1a7937ae795b46c885fd3edf871fe8cbb2468e (patch)
treebcfd0c424e67d876ed5a61d30eaafede2ad116a5 /src
parent5c037f4745e5a9a3c5f5d050c59d39e3f763bb5a (diff)
downloadqtlocation-mapboxgl-4a1a7937ae795b46c885fd3edf871fe8cbb2468e.tar.gz
[core] Move set/get thread names to platform::
Android needs its own implementation.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/platform/log.cpp2
-rw-r--r--src/mbgl/util/thread.hpp25
2 files changed, 2 insertions, 25 deletions
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<Event>::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 <class Object>
template <class... Args>
Thread<Object>::Thread(const ThreadContext& context, Args&&... args) {
@@ -117,7 +94,7 @@ Thread<Object>::Thread(const ThreadContext& context, Args&&... args) {
std::tuple<Args...> params = std::forward_as_tuple(::std::forward<Args>(args)...);
thread = std::thread([&] {
- setCurrentThreadName(context.name);
+ platform::setCurrentThreadName(context.name);
if (context.priority == ThreadPriority::Low) {
platform::makeThreadLowPriority();