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

Unified Diff: base/threading/platform_thread_win.cc

Issue 14634009: Move Thread Name Mapping into ThreadFunc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
Index: base/threading/platform_thread_win.cc
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 9e877b32f9e1e630ce31c164f5e58680b898e5f7..b47f2b38f6b5e6946fb2e5ec6bf99d648396e1d9 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -46,6 +46,7 @@ void SetNameInternal(PlatformThreadId thread_id, const char* name) {
struct ThreadParams {
PlatformThread::Delegate* delegate;
bool joinable;
+ PlatformThreadHandle* thread_handle;
};
DWORD __stdcall ThreadFunc(void* params) {
@@ -53,6 +54,10 @@ DWORD __stdcall ThreadFunc(void* params) {
PlatformThread::Delegate* delegate = thread_params->delegate;
if (!thread_params->joinable)
base::ThreadRestrictions::SetSingletonAllowed(false);
+
+ ThreadIdNameManager::GetInstance()->RegisterThread(
+ thread_params->thread_handle,
+ PlatformThread::CurrentId());
delete thread_params;
delegate->ThreadMain();
return NULL;
jar (doing other things) 2013/05/22 19:37:56 Wouldn't this be a great place to unregister, just
dsinclair 2013/05/22 20:22:31 The benefit I see from having it in the Join metho
jar (doing other things) 2013/05/22 21:36:48 I think that by the time you hit line 63, any mess
dsinclair 2013/05/23 18:21:53 Done.
@@ -75,6 +80,7 @@ bool CreateThreadInternal(size_t stack_size,
ThreadParams* params = new ThreadParams;
params->delegate = delegate;
params->joinable = out_thread_handle != NULL;
+ params->thread_handle = out_thread_handle;
// Using CreateThread here vs _beginthreadex makes thread creation a bit
// faster and doesn't require the loader lock to be available. Our code will

Powered by Google App Engine
This is Rietveld 408576698