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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include "base/debug/alias.h" 7 #include "base/debug/alias.h"
8 #include "base/debug/profiler.h" 8 #include "base/debug/profiler.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_id_name_manager.h" 10 #include "base/threading/thread_id_name_manager.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 struct ThreadParams { 46 struct ThreadParams {
47 PlatformThread::Delegate* delegate; 47 PlatformThread::Delegate* delegate;
48 bool joinable; 48 bool joinable;
49 }; 49 };
50 50
51 DWORD __stdcall ThreadFunc(void* params) { 51 DWORD __stdcall ThreadFunc(void* params) {
52 ThreadParams* thread_params = static_cast<ThreadParams*>(params); 52 ThreadParams* thread_params = static_cast<ThreadParams*>(params);
53 PlatformThread::Delegate* delegate = thread_params->delegate; 53 PlatformThread::Delegate* delegate = thread_params->delegate;
54 if (!thread_params->joinable) 54 if (!thread_params->joinable)
55 base::ThreadRestrictions::SetSingletonAllowed(false); 55 base::ThreadRestrictions::SetSingletonAllowed(false);
56
57 /* Retrieve a copy of the thread handle to use as the key in the
58 * thread name mapping. */
59 PlatformThreadHandle::Handle platform_handle;
60 DuplicateHandle(
61 GetCurrentProcess(),
62 GetCurrentThread(),
63 GetCurrentProcess(),
64 &platform_handle,
65 0,
66 FALSE,
67 DUPLICATE_SAME_ACCESS);
68
69 ThreadIdNameManager::GetInstance()->RegisterThread(
70 platform_handle,
71 PlatformThread::CurrentId());
72
56 delete thread_params; 73 delete thread_params;
57 delegate->ThreadMain(); 74 delegate->ThreadMain();
75
76 ThreadIdNameManager::GetInstance()->RemoveName(
77 platform_handle,
78 PlatformThread::CurrentId());
58 return NULL; 79 return NULL;
59 } 80 }
60 81
61 // CreateThreadInternal() matches PlatformThread::Create(), except that 82 // CreateThreadInternal() matches PlatformThread::Create(), except that
62 // |out_thread_handle| may be NULL, in which case a non-joinable thread is 83 // |out_thread_handle| may be NULL, in which case a non-joinable thread is
63 // created. 84 // created.
64 bool CreateThreadInternal(size_t stack_size, 85 bool CreateThreadInternal(size_t stack_size,
65 PlatformThread::Delegate* delegate, 86 PlatformThread::Delegate* delegate,
66 PlatformThreadHandle* out_thread_handle) { 87 PlatformThreadHandle* out_thread_handle) {
67 unsigned int flags = 0; 88 unsigned int flags = 0;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 case kThreadPriority_RealtimeAudio: 225 case kThreadPriority_RealtimeAudio:
205 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); 226 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL);
206 break; 227 break;
207 default: 228 default:
208 NOTREACHED() << "Unknown priority."; 229 NOTREACHED() << "Unknown priority.";
209 break; 230 break;
210 } 231 }
211 } 232 }
212 233
213 } // namespace base 234 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698