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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "vm/os_thread.h" | 8 #include "vm/os_thread.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 RETURN_ON_PTHREAD_FAILURE(result); | 110 RETURN_ON_PTHREAD_FAILURE(result); |
111 | 111 |
112 return 0; | 112 return 0; |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 ThreadLocalKey OSThread::kUnsetThreadLocalKey = | 116 ThreadLocalKey OSThread::kUnsetThreadLocalKey = |
117 static_cast<pthread_key_t>(-1); | 117 static_cast<pthread_key_t>(-1); |
118 ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0); | 118 ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0); |
119 | 119 |
120 ThreadLocalKey OSThread::CreateThreadLocal() { | 120 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { |
121 pthread_key_t key = kUnsetThreadLocalKey; | 121 pthread_key_t key = kUnsetThreadLocalKey; |
122 int result = pthread_key_create(&key, NULL); | 122 int result = pthread_key_create(&key, destructor); |
123 VALIDATE_PTHREAD_RESULT(result); | 123 VALIDATE_PTHREAD_RESULT(result); |
124 ASSERT(key != kUnsetThreadLocalKey); | 124 ASSERT(key != kUnsetThreadLocalKey); |
125 return key; | 125 return key; |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 void OSThread::DeleteThreadLocal(ThreadLocalKey key) { | 129 void OSThread::DeleteThreadLocal(ThreadLocalKey key) { |
130 ASSERT(key != kUnsetThreadLocalKey); | 130 ASSERT(key != kUnsetThreadLocalKey); |
131 int result = pthread_key_delete(key); | 131 int result = pthread_key_delete(key); |
132 VALIDATE_PTHREAD_RESULT(result); | 132 VALIDATE_PTHREAD_RESULT(result); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 void Monitor::NotifyAll() { | 343 void Monitor::NotifyAll() { |
344 // TODO(iposva): Do we need to track lock owners? | 344 // TODO(iposva): Do we need to track lock owners? |
345 int result = pthread_cond_broadcast(data_.cond()); | 345 int result = pthread_cond_broadcast(data_.cond()); |
346 VALIDATE_PTHREAD_RESULT(result); | 346 VALIDATE_PTHREAD_RESULT(result); |
347 } | 347 } |
348 | 348 |
349 } // namespace dart | 349 } // namespace dart |
350 | 350 |
351 #endif // defined(TARGET_OS_LINUX) | 351 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |