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

Side by Side Diff: base/threading/platform_thread_posix.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 | « no previous file | base/threading/platform_thread_win.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 <errno.h> 7 #include <errno.h>
8 #include <sched.h> 8 #include <sched.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 PlatformThread::SetThreadPriority(PlatformThread::CurrentHandle(), 66 PlatformThread::SetThreadPriority(PlatformThread::CurrentHandle(),
67 thread_params->priority); 67 thread_params->priority);
68 } 68 }
69 69
70 // Stash the id in the handle so the calling thread has a complete 70 // Stash the id in the handle so the calling thread has a complete
71 // handle, and unblock the parent thread. 71 // handle, and unblock the parent thread.
72 *(thread_params->handle) = PlatformThreadHandle(pthread_self(), 72 *(thread_params->handle) = PlatformThreadHandle(pthread_self(),
73 PlatformThread::CurrentId()); 73 PlatformThread::CurrentId());
74 thread_params->handle_set.Signal(); 74 thread_params->handle_set.Signal();
75 75
76 ThreadIdNameManager::GetInstance()->RegisterThread(
77 PlatformThread::CurrentHandle().platform_handle(),
78 PlatformThread::CurrentId());
79
76 delegate->ThreadMain(); 80 delegate->ThreadMain();
77 81
82 ThreadIdNameManager::GetInstance()->RemoveName(
83 PlatformThread::CurrentHandle().platform_handle(),
84 PlatformThread::CurrentId());
85
78 base::TerminateOnThread(); 86 base::TerminateOnThread();
79 return NULL; 87 return NULL;
80 } 88 }
81 89
82 bool CreateThread(size_t stack_size, bool joinable, 90 bool CreateThread(size_t stack_size, bool joinable,
83 PlatformThread::Delegate* delegate, 91 PlatformThread::Delegate* delegate,
84 PlatformThreadHandle* thread_handle, 92 PlatformThreadHandle* thread_handle,
85 ThreadPriority priority) { 93 ThreadPriority priority) {
86 base::InitThreading(); 94 base::InitThreading();
87 95
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // static 222 // static
215 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 223 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
216 // Joining another thread may block the current thread for a long time, since 224 // Joining another thread may block the current thread for a long time, since
217 // the thread referred to by |thread_handle| may still be running long-lived / 225 // the thread referred to by |thread_handle| may still be running long-lived /
218 // blocking tasks. 226 // blocking tasks.
219 base::ThreadRestrictions::AssertIOAllowed(); 227 base::ThreadRestrictions::AssertIOAllowed();
220 pthread_join(thread_handle.handle_, NULL); 228 pthread_join(thread_handle.handle_, NULL);
221 } 229 }
222 230
223 } // namespace base 231 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698