Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3950)

Unified Diff: base/threading/platform_thread_posix.cc

Issue 11438022: Add ability to retrieve a thread_name given a thread_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make some of the try servers happier. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/platform_thread_mac.mm ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_posix.cc
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index b17c34d43d5ccaf92275616147976156b62b6567..b02a60858f954469037cf18c66d2716cf4479234 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -11,7 +11,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/safe_strerror_posix.h"
-#include "base/threading/thread_local.h"
+#include "base/threading/thread_id_name_manager.h"
#include "base/threading/thread_restrictions.h"
#include "base/tracked_objects.h"
@@ -46,12 +46,6 @@ void InitThreading();
namespace {
-#if !defined(OS_MACOSX)
-// Mac name code is in in platform_thread_mac.mm.
-LazyInstance<ThreadLocalPointer<char> >::Leaky
- current_thread_name = LAZY_INSTANCE_INITIALIZER;
-#endif
-
struct ThreadParams {
PlatformThread::Delegate* delegate;
bool joinable;
@@ -203,9 +197,7 @@ void PlatformThread::Sleep(TimeDelta duration) {
#if defined(OS_LINUX)
// static
void PlatformThread::SetName(const char* name) {
- // have to cast away const because ThreadLocalPointer does not support const
- // void*
- current_thread_name.Pointer()->Set(const_cast<char*>(name));
+ ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
// On linux we can get the thread names to show up in the debugger by setting
@@ -230,9 +222,7 @@ void PlatformThread::SetName(const char* name) {
#else
// static
void PlatformThread::SetName(const char* name) {
- // have to cast away const because ThreadLocalPointer does not support const
- // void*
- current_thread_name.Pointer()->Set(const_cast<char*>(name));
+ ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
tracked_objects::ThreadData::InitializeThreadContext(name);
// (This should be relatively simple to implement for the BSDs; I
@@ -240,14 +230,10 @@ void PlatformThread::SetName(const char* name) {
}
#endif // defined(OS_LINUX)
-
-#if !defined(OS_MACOSX)
-// Mac is implemented in platform_thread_mac.mm.
// static
const char* PlatformThread::GetName() {
- return current_thread_name.Pointer()->Get();
+ return ThreadIdNameManager::GetInstance()->GetName(CurrentId());
}
-#endif
// static
bool PlatformThread::Create(size_t stack_size, Delegate* delegate,
« no previous file with comments | « base/threading/platform_thread_mac.mm ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698