Index: base/threading/platform_thread_mac.mm |
diff --git a/base/threading/platform_thread_mac.mm b/base/threading/platform_thread_mac.mm |
index 7d5906403c7d55d7ba74ad40d25cb52cd9336f64..1bf322079e656fc59ccecfb609479148c132ce95 100644 |
--- a/base/threading/platform_thread_mac.mm |
+++ b/base/threading/platform_thread_mac.mm |
@@ -11,9 +11,16 @@ |
#include <mach/thread_policy.h> |
#include "base/logging.h" |
+#include "base/threading/thread_local.h" |
namespace base { |
+namespace { |
+ |
+static ThreadLocalPointer<char> current_thread_name; |
+ |
+} |
brettw
2011/08/08 20:10:37
Nee // namespace
|
+ |
// If Cocoa is to be used on more than one thread, it must know that the |
// application is multithreaded. Since it's possible to enter Cocoa code |
// from threads created by pthread_thread_create, Cocoa won't necessarily |
@@ -37,6 +44,8 @@ void InitThreading() { |
// static |
void PlatformThread::SetName(const char* name) { |
+ current_thread_name.Set(const_cast<char*>(name)); |
+ |
// pthread_setname_np is only available in 10.6 or later, so test |
// for it at runtime. |
int (*dynamic_pthread_setname_np)(const char*); |
@@ -54,6 +63,11 @@ void PlatformThread::SetName(const char* name) { |
dynamic_pthread_setname_np(shortened_name.c_str()); |
} |
+// static |
+const char* PlatformThread::GetName() { |
+ return current_thread_name.Get(); |
+} |
+ |
namespace { |
void SetPriorityNormal(mach_port_t mach_thread_id) { |