| 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" // NOLINT | 5 #include "platform/globals.h" // NOLINT |
| 6 #include "platform/signal_blocker.h" // NOLINT | 6 #include "platform/signal_blocker.h" // NOLINT |
| 7 | 7 |
| 8 #if defined(TARGET_OS_ANDROID) | 8 #if defined(TARGET_OS_ANDROID) |
| 9 | 9 |
| 10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { | 212 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { |
| 213 return static_cast<ThreadId>(id); | 213 return static_cast<ThreadId>(id); |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 bool OSThread::Compare(ThreadId a, ThreadId b) { | 217 bool OSThread::Compare(ThreadId a, ThreadId b) { |
| 218 return a == b; | 218 return a == b; |
| 219 } | 219 } |
| 220 | 220 |
| 221 | 221 |
| 222 void OSThread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { | |
| 223 ASSERT(thread_id == GetCurrentThreadId()); | |
| 224 ASSERT(cpu_usage != NULL); | |
| 225 struct timespec ts; | |
| 226 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); | |
| 227 ASSERT(r == 0); | |
| 228 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / | |
| 229 kNanosecondsPerMicrosecond; | |
| 230 } | |
| 231 | |
| 232 | |
| 233 Mutex::Mutex() { | 222 Mutex::Mutex() { |
| 234 pthread_mutexattr_t attr; | 223 pthread_mutexattr_t attr; |
| 235 int result = pthread_mutexattr_init(&attr); | 224 int result = pthread_mutexattr_init(&attr); |
| 236 VALIDATE_PTHREAD_RESULT(result); | 225 VALIDATE_PTHREAD_RESULT(result); |
| 237 | 226 |
| 238 #if defined(DEBUG) | 227 #if defined(DEBUG) |
| 239 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); | 228 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); |
| 240 VALIDATE_PTHREAD_RESULT(result); | 229 VALIDATE_PTHREAD_RESULT(result); |
| 241 #endif // defined(DEBUG) | 230 #endif // defined(DEBUG) |
| 242 | 231 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 void Monitor::NotifyAll() { | 431 void Monitor::NotifyAll() { |
| 443 // When running with assertions enabled we track the owner. | 432 // When running with assertions enabled we track the owner. |
| 444 ASSERT(IsOwnedByCurrentThread()); | 433 ASSERT(IsOwnedByCurrentThread()); |
| 445 int result = pthread_cond_broadcast(data_.cond()); | 434 int result = pthread_cond_broadcast(data_.cond()); |
| 446 VALIDATE_PTHREAD_RESULT(result); | 435 VALIDATE_PTHREAD_RESULT(result); |
| 447 } | 436 } |
| 448 | 437 |
| 449 } // namespace dart | 438 } // namespace dart |
| 450 | 439 |
| 451 #endif // defined(TARGET_OS_ANDROID) | 440 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |