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

Side by Side Diff: base/threading/platform_thread_posix.cc

Issue 2135413003: Add |joinable| to Thread::Options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ignore SetMessageLoop(nullptr) for now -- added TODO Created 4 years, 4 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
« no previous file with comments | « base/threading/platform_thread.h ('k') | 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 <pthread.h> 8 #include <pthread.h>
9 #include <sched.h> 9 #include <sched.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 // static 181 // static
182 const char* PlatformThread::GetName() { 182 const char* PlatformThread::GetName() {
183 return ThreadIdNameManager::GetInstance()->GetName(CurrentId()); 183 return ThreadIdNameManager::GetInstance()->GetName(CurrentId());
184 } 184 }
185 185
186 // static 186 // static
187 bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate, 187 bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate,
188 PlatformThreadHandle* thread_handle, 188 PlatformThreadHandle* thread_handle,
189 ThreadPriority priority) { 189 ThreadPriority priority) {
190 return CreateThread(stack_size, true, // joinable thread 190 return CreateThread(stack_size, true /* joinable thread */, delegate,
191 delegate, thread_handle, priority); 191 thread_handle, priority);
192 } 192 }
193 193
194 // static 194 // static
195 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { 195 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) {
196 return CreateNonJoinableWithPriority(stack_size, delegate,
197 ThreadPriority::NORMAL);
198 }
199
200 // static
201 bool PlatformThread::CreateNonJoinableWithPriority(size_t stack_size,
202 Delegate* delegate,
203 ThreadPriority priority) {
196 PlatformThreadHandle unused; 204 PlatformThreadHandle unused;
197 205
198 bool result = CreateThread(stack_size, false /* non-joinable thread */, 206 bool result = CreateThread(stack_size, false /* non-joinable thread */,
199 delegate, &unused, ThreadPriority::NORMAL); 207 delegate, &unused, priority);
200 return result; 208 return result;
201 } 209 }
202 210
203 // static 211 // static
204 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 212 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
205 // Joining another thread may block the current thread for a long time, since 213 // Joining another thread may block the current thread for a long time, since
206 // the thread referred to by |thread_handle| may still be running long-lived / 214 // the thread referred to by |thread_handle| may still be running long-lived /
207 // blocking tasks. 215 // blocking tasks.
208 base::ThreadRestrictions::AssertIOAllowed(); 216 base::ThreadRestrictions::AssertIOAllowed();
209 CHECK_EQ(0, pthread_join(thread_handle.platform_handle(), NULL)); 217 CHECK_EQ(0, pthread_join(thread_handle.platform_handle(), NULL));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return ThreadPriority::NORMAL; 282 return ThreadPriority::NORMAL;
275 } 283 }
276 284
277 return internal::NiceValueToThreadPriority(nice_value); 285 return internal::NiceValueToThreadPriority(nice_value);
278 #endif // !defined(OS_NACL) 286 #endif // !defined(OS_NACL)
279 } 287 }
280 288
281 #endif // !defined(OS_MACOSX) 289 #endif // !defined(OS_MACOSX)
282 290
283 } // namespace base 291 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698