| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |