| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 #include "bin/thread_android.h" | 9 #include "bin/thread_android.h" |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 ASSERT(sizeof(id) == sizeof(intptr_t)); | 158 ASSERT(sizeof(id) == sizeof(intptr_t)); |
| 159 return static_cast<intptr_t>(id); | 159 return static_cast<intptr_t>(id); |
| 160 } | 160 } |
| 161 | 161 |
| 162 | 162 |
| 163 bool Thread::Compare(ThreadId a, ThreadId b) { | 163 bool Thread::Compare(ThreadId a, ThreadId b) { |
| 164 return (a == b); | 164 return (a == b); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { | |
| 169 ASSERT(thread_id == GetCurrentThreadId()); | |
| 170 ASSERT(cpu_usage != NULL); | |
| 171 struct timespec ts; | |
| 172 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); | |
| 173 ASSERT(r == 0); | |
| 174 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / | |
| 175 kNanosecondsPerMicrosecond; | |
| 176 } | |
| 177 | |
| 178 | |
| 179 void Thread::InitOnce() { | 168 void Thread::InitOnce() { |
| 180 // Nothing to be done. | 169 // Nothing to be done. |
| 181 } | 170 } |
| 182 | 171 |
| 183 | 172 |
| 184 Mutex::Mutex() { | 173 Mutex::Mutex() { |
| 185 pthread_mutexattr_t attr; | 174 pthread_mutexattr_t attr; |
| 186 int result = pthread_mutexattr_init(&attr); | 175 int result = pthread_mutexattr_init(&attr); |
| 187 VALIDATE_PTHREAD_RESULT(result); | 176 VALIDATE_PTHREAD_RESULT(result); |
| 188 | 177 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void Monitor::NotifyAll() { | 312 void Monitor::NotifyAll() { |
| 324 // TODO(iposva): Do we need to track lock owners? | 313 // TODO(iposva): Do we need to track lock owners? |
| 325 int result = pthread_cond_broadcast(data_.cond()); | 314 int result = pthread_cond_broadcast(data_.cond()); |
| 326 VALIDATE_PTHREAD_RESULT(result); | 315 VALIDATE_PTHREAD_RESULT(result); |
| 327 } | 316 } |
| 328 | 317 |
| 329 } // namespace bin | 318 } // namespace bin |
| 330 } // namespace dart | 319 } // namespace dart |
| 331 | 320 |
| 332 #endif // defined(TARGET_OS_ANDROID) | 321 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |