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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 RETURN_ON_PTHREAD_FAILURE(result); | 102 RETURN_ON_PTHREAD_FAILURE(result); |
103 | 103 |
104 return 0; | 104 return 0; |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 ThreadLocalKey OSThread::kUnsetThreadLocalKey = | 108 ThreadLocalKey OSThread::kUnsetThreadLocalKey = |
109 static_cast<pthread_key_t>(-1); | 109 static_cast<pthread_key_t>(-1); |
110 ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL); | 110 ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL); |
111 | 111 |
112 ThreadLocalKey OSThread::CreateThreadLocal() { | 112 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { |
113 pthread_key_t key = kUnsetThreadLocalKey; | 113 pthread_key_t key = kUnsetThreadLocalKey; |
114 int result = pthread_key_create(&key, NULL); | 114 int result = pthread_key_create(&key, destructor); |
115 VALIDATE_PTHREAD_RESULT(result); | 115 VALIDATE_PTHREAD_RESULT(result); |
116 ASSERT(key != kUnsetThreadLocalKey); | 116 ASSERT(key != kUnsetThreadLocalKey); |
117 return key; | 117 return key; |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 void OSThread::DeleteThreadLocal(ThreadLocalKey key) { | 121 void OSThread::DeleteThreadLocal(ThreadLocalKey key) { |
122 ASSERT(key != kUnsetThreadLocalKey); | 122 ASSERT(key != kUnsetThreadLocalKey); |
123 int result = pthread_key_delete(key); | 123 int result = pthread_key_delete(key); |
124 VALIDATE_PTHREAD_RESULT(result); | 124 VALIDATE_PTHREAD_RESULT(result); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 void Monitor::NotifyAll() { | 348 void Monitor::NotifyAll() { |
349 // TODO(iposva): Do we need to track lock owners? | 349 // TODO(iposva): Do we need to track lock owners? |
350 int result = pthread_cond_broadcast(data_.cond()); | 350 int result = pthread_cond_broadcast(data_.cond()); |
351 VALIDATE_PTHREAD_RESULT(result); | 351 VALIDATE_PTHREAD_RESULT(result); |
352 } | 352 } |
353 | 353 |
354 } // namespace dart | 354 } // namespace dart |
355 | 355 |
356 #endif // defined(TARGET_OS_MACOS) | 356 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |