| 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 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include "vm/os_thread.h" | 8 #include "vm/os_thread.h" |
| 9 | 9 |
| 10 #include <sys/errno.h> // NOLINT | 10 #include <sys/errno.h> // NOLINT |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (r == KERN_SUCCESS) { | 210 if (r == KERN_SUCCESS) { |
| 211 *cpu_usage = (info->user_time.seconds * kMicrosecondsPerSecond) + | 211 *cpu_usage = (info->user_time.seconds * kMicrosecondsPerSecond) + |
| 212 info->user_time.microseconds; | 212 info->user_time.microseconds; |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 *cpu_usage = 0; | 216 *cpu_usage = 0; |
| 217 } | 217 } |
| 218 | 218 |
| 219 | 219 |
| 220 Mutex::Mutex() { | 220 Mutex::Mutex(bool recursive) { |
| 221 pthread_mutexattr_t attr; | 221 pthread_mutexattr_t attr; |
| 222 int result = pthread_mutexattr_init(&attr); | 222 int result = pthread_mutexattr_init(&attr); |
| 223 VALIDATE_PTHREAD_RESULT(result); | 223 VALIDATE_PTHREAD_RESULT(result); |
| 224 | 224 |
| 225 #if defined(DEBUG) | 225 #if defined(DEBUG) |
| 226 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); | 226 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); |
| 227 VALIDATE_PTHREAD_RESULT(result); | 227 VALIDATE_PTHREAD_RESULT(result); |
| 228 #endif // defined(DEBUG) | 228 #endif // defined(DEBUG) |
| 229 | 229 |
| 230 if (recursive) { |
| 231 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); |
| 232 VALIDATE_PTHREAD_RESULT(result); |
| 233 } |
| 234 |
| 230 result = pthread_mutex_init(data_.mutex(), &attr); | 235 result = pthread_mutex_init(data_.mutex(), &attr); |
| 231 // Verify that creating a pthread_mutex succeeded. | 236 // Verify that creating a pthread_mutex succeeded. |
| 232 VALIDATE_PTHREAD_RESULT(result); | 237 VALIDATE_PTHREAD_RESULT(result); |
| 233 | 238 |
| 234 result = pthread_mutexattr_destroy(&attr); | 239 result = pthread_mutexattr_destroy(&attr); |
| 235 VALIDATE_PTHREAD_RESULT(result); | 240 VALIDATE_PTHREAD_RESULT(result); |
| 236 | 241 |
| 237 #if defined(DEBUG) | 242 #if defined(DEBUG) |
| 238 // When running with assertions enabled we do track the owner. | 243 // When running with assertions enabled we do track the owner. |
| 239 owner_ = OSThread::kInvalidThreadId; | 244 owner_ = OSThread::kInvalidThreadId; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void Monitor::NotifyAll() { | 421 void Monitor::NotifyAll() { |
| 417 // When running with assertions enabled we track the owner. | 422 // When running with assertions enabled we track the owner. |
| 418 ASSERT(IsOwnedByCurrentThread()); | 423 ASSERT(IsOwnedByCurrentThread()); |
| 419 int result = pthread_cond_broadcast(data_.cond()); | 424 int result = pthread_cond_broadcast(data_.cond()); |
| 420 VALIDATE_PTHREAD_RESULT(result); | 425 VALIDATE_PTHREAD_RESULT(result); |
| 421 } | 426 } |
| 422 | 427 |
| 423 } // namespace dart | 428 } // namespace dart |
| 424 | 429 |
| 425 #endif // defined(TARGET_OS_MACOS) | 430 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |