OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ASSERT(thread_id == GetCurrentThreadId()); | 171 ASSERT(thread_id == GetCurrentThreadId()); |
172 ASSERT(cpu_usage != NULL); | 172 ASSERT(cpu_usage != NULL); |
173 struct timespec ts; | 173 struct timespec ts; |
174 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); | 174 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); |
175 ASSERT(r == 0); | 175 ASSERT(r == 0); |
176 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / | 176 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / |
177 kNanosecondsPerMicrosecond; | 177 kNanosecondsPerMicrosecond; |
178 } | 178 } |
179 | 179 |
180 | 180 |
| 181 void Thread::InitOnce() { |
| 182 // Nothing to be done. |
| 183 } |
| 184 |
| 185 |
181 Mutex::Mutex() { | 186 Mutex::Mutex() { |
182 pthread_mutexattr_t attr; | 187 pthread_mutexattr_t attr; |
183 int result = pthread_mutexattr_init(&attr); | 188 int result = pthread_mutexattr_init(&attr); |
184 VALIDATE_PTHREAD_RESULT(result); | 189 VALIDATE_PTHREAD_RESULT(result); |
185 | 190 |
186 #if defined(DEBUG) | 191 #if defined(DEBUG) |
187 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); | 192 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); |
188 VALIDATE_PTHREAD_RESULT(result); | 193 VALIDATE_PTHREAD_RESULT(result); |
189 #endif // defined(DEBUG) | 194 #endif // defined(DEBUG) |
190 | 195 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 void Monitor::NotifyAll() { | 328 void Monitor::NotifyAll() { |
324 // TODO(iposva): Do we need to track lock owners? | 329 // TODO(iposva): Do we need to track lock owners? |
325 int result = pthread_cond_broadcast(data_.cond()); | 330 int result = pthread_cond_broadcast(data_.cond()); |
326 VALIDATE_PTHREAD_RESULT(result); | 331 VALIDATE_PTHREAD_RESULT(result); |
327 } | 332 } |
328 | 333 |
329 } // namespace bin | 334 } // namespace bin |
330 } // namespace dart | 335 } // namespace dart |
331 | 336 |
332 #endif // defined(TARGET_OS_LINUX) | 337 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |