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

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

Issue 1256903005: base/threading: fix a potential race issue on start_event_ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [rebase] Created 5 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 | « no previous file | base/threading/thread.h » ('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 <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 if (stack_size > 0) 94 if (stack_size > 0)
95 pthread_attr_setstacksize(&attributes, stack_size); 95 pthread_attr_setstacksize(&attributes, stack_size);
96 96
97 scoped_ptr<ThreadParams> params(new ThreadParams); 97 scoped_ptr<ThreadParams> params(new ThreadParams);
98 params->delegate = delegate; 98 params->delegate = delegate;
99 params->joinable = joinable; 99 params->joinable = joinable;
100 params->priority = priority; 100 params->priority = priority;
101 101
102 pthread_t handle; 102 pthread_t handle;
103 int err = 103 int err = pthread_create(&handle, &attributes, ThreadFunc, params.get());
104 pthread_create(&handle, &attributes, ThreadFunc, params.get());
105 bool success = !err; 104 bool success = !err;
106 if (success) { 105 if (success) {
107 // ThreadParams should be deleted on the created thread after used. 106 // ThreadParams should be deleted on the created thread after used.
108 ignore_result(params.release()); 107 ignore_result(params.release());
109 } else { 108 } else {
110 // Value of |handle| is undefined if pthread_create fails. 109 // Value of |handle| is undefined if pthread_create fails.
111 handle = 0; 110 handle = 0;
112 errno = err; 111 errno = err;
113 PLOG(ERROR) << "pthread_create"; 112 PLOG(ERROR) << "pthread_create";
114 } 113 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return ThreadPriority::NORMAL; 251 return ThreadPriority::NORMAL;
253 } 252 }
254 253
255 return internal::NiceValueToThreadPriority(nice_value); 254 return internal::NiceValueToThreadPriority(nice_value);
256 #endif // !defined(OS_NACL) 255 #endif // !defined(OS_NACL)
257 } 256 }
258 257
259 #endif // !defined(OS_MACOSX) 258 #endif // !defined(OS_MACOSX)
260 259
261 } // namespace base 260 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698