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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ThreadId OSThread::GetCurrentThreadId() { | 161 ThreadId OSThread::GetCurrentThreadId() { |
162 return pthread_self(); | 162 return pthread_self(); |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 ThreadId OSThread::GetCurrentThreadTraceId() { | 166 ThreadId OSThread::GetCurrentThreadTraceId() { |
167 return ThreadIdFromIntPtr(pthread_mach_thread_np(pthread_self())); | 167 return ThreadIdFromIntPtr(pthread_mach_thread_np(pthread_self())); |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 ThreadJoinId OSThread::GetCurrentThreadJoinId() { | 171 ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) { |
172 return pthread_self(); | 172 ASSERT(thread != NULL); |
| 173 // Make sure we're filling in the join id for the current thread. |
| 174 ASSERT(thread->id() == GetCurrentThreadId()); |
| 175 // Make sure the join_id_ hasn't been set, yet. |
| 176 DEBUG_ASSERT(thread->join_id_ == kInvalidThreadJoinId); |
| 177 pthread_t id = pthread_self(); |
| 178 #if defined(DEBUG) |
| 179 thread->join_id_ = id; |
| 180 #endif |
| 181 return id; |
173 } | 182 } |
174 | 183 |
175 | 184 |
176 void OSThread::Join(ThreadJoinId id) { | 185 void OSThread::Join(ThreadJoinId id) { |
177 int result = pthread_join(id, NULL); | 186 int result = pthread_join(id, NULL); |
178 ASSERT(result == 0); | 187 ASSERT(result == 0); |
179 } | 188 } |
180 | 189 |
181 | 190 |
182 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { | 191 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 void Monitor::NotifyAll() { | 419 void Monitor::NotifyAll() { |
411 // When running with assertions enabled we track the owner. | 420 // When running with assertions enabled we track the owner. |
412 ASSERT(IsOwnedByCurrentThread()); | 421 ASSERT(IsOwnedByCurrentThread()); |
413 int result = pthread_cond_broadcast(data_.cond()); | 422 int result = pthread_cond_broadcast(data_.cond()); |
414 VALIDATE_PTHREAD_RESULT(result); | 423 VALIDATE_PTHREAD_RESULT(result); |
415 } | 424 } |
416 | 425 |
417 } // namespace dart | 426 } // namespace dart |
418 | 427 |
419 #endif // defined(TARGET_OS_MACOS) | 428 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |