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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 return NULL; | 88 return NULL; |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 int OSThread::Start(ThreadStartFunction function, uword parameter) { | 92 int OSThread::Start(ThreadStartFunction function, uword parameter) { |
93 pthread_attr_t attr; | 93 pthread_attr_t attr; |
94 int result = pthread_attr_init(&attr); | 94 int result = pthread_attr_init(&attr); |
95 RETURN_ON_PTHREAD_FAILURE(result); | 95 RETURN_ON_PTHREAD_FAILURE(result); |
96 | 96 |
97 result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | |
98 RETURN_ON_PTHREAD_FAILURE(result); | |
99 | |
100 result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize()); | 97 result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize()); |
101 RETURN_ON_PTHREAD_FAILURE(result); | 98 RETURN_ON_PTHREAD_FAILURE(result); |
102 | 99 |
103 ThreadStartData* data = new ThreadStartData(function, parameter); | 100 ThreadStartData* data = new ThreadStartData(function, parameter); |
104 | 101 |
105 pthread_t tid; | 102 pthread_t tid; |
106 result = pthread_create(&tid, &attr, ThreadStart, data); | 103 result = pthread_create(&tid, &attr, ThreadStart, data); |
107 RETURN_ON_PTHREAD_FAILURE(result); | 104 RETURN_ON_PTHREAD_FAILURE(result); |
108 | 105 |
109 result = pthread_attr_destroy(&attr); | 106 result = pthread_attr_destroy(&attr); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return kStackSize; | 142 return kStackSize; |
146 } | 143 } |
147 | 144 |
148 | 145 |
149 ThreadId OSThread::GetCurrentThreadId() { | 146 ThreadId OSThread::GetCurrentThreadId() { |
150 return pthread_self(); | 147 return pthread_self(); |
151 } | 148 } |
152 | 149 |
153 | 150 |
154 bool OSThread::Join(ThreadId id) { | 151 bool OSThread::Join(ThreadId id) { |
155 return false; | 152 return pthread_join(id, NULL) == 0; |
156 } | 153 } |
157 | 154 |
158 | 155 |
159 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { | 156 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { |
160 ASSERT(sizeof(id) == sizeof(intptr_t)); | 157 ASSERT(sizeof(id) == sizeof(intptr_t)); |
161 return reinterpret_cast<intptr_t>(id); | 158 return reinterpret_cast<intptr_t>(id); |
162 } | 159 } |
163 | 160 |
164 | 161 |
165 bool OSThread::Compare(ThreadId a, ThreadId b) { | 162 bool OSThread::Compare(ThreadId a, ThreadId b) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 352 |
356 void Monitor::NotifyAll() { | 353 void Monitor::NotifyAll() { |
357 // TODO(iposva): Do we need to track lock owners? | 354 // TODO(iposva): Do we need to track lock owners? |
358 int result = pthread_cond_broadcast(data_.cond()); | 355 int result = pthread_cond_broadcast(data_.cond()); |
359 VALIDATE_PTHREAD_RESULT(result); | 356 VALIDATE_PTHREAD_RESULT(result); |
360 } | 357 } |
361 | 358 |
362 } // namespace dart | 359 } // namespace dart |
363 | 360 |
364 #endif // defined(TARGET_OS_MACOS) | 361 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |