| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // exits. | 81 // exits. |
| 82 static void* ThreadStart(void* data_ptr) { | 82 static void* ThreadStart(void* data_ptr) { |
| 83 ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr); | 83 ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr); |
| 84 | 84 |
| 85 const char* name = data->name(); | 85 const char* name = data->name(); |
| 86 OSThread::ThreadStartFunction function = data->function(); | 86 OSThread::ThreadStartFunction function = data->function(); |
| 87 uword parameter = data->parameter(); | 87 uword parameter = data->parameter(); |
| 88 delete data; | 88 delete data; |
| 89 | 89 |
| 90 // Create new OSThread object and set as TLS for new thread. | 90 // Create new OSThread object and set as TLS for new thread. |
| 91 OSThread* thread = new OSThread(); | 91 OSThread* thread = OSThread::CreateOSThread(); |
| 92 OSThread::SetCurrent(thread); | 92 if (thread != NULL) { |
| 93 thread->set_name(name); | 93 OSThread::SetCurrent(thread); |
| 94 thread->set_name(name); |
| 94 | 95 |
| 95 // Call the supplied thread start function handing it its parameters. | 96 // Call the supplied thread start function handing it its parameters. |
| 96 function(parameter); | 97 function(parameter); |
| 98 } |
| 97 | 99 |
| 98 return NULL; | 100 return NULL; |
| 99 } | 101 } |
| 100 | 102 |
| 101 | 103 |
| 102 int OSThread::Start(const char* name, | 104 int OSThread::Start(const char* name, |
| 103 ThreadStartFunction function, | 105 ThreadStartFunction function, |
| 104 uword parameter) { | 106 uword parameter) { |
| 105 pthread_attr_t attr; | 107 pthread_attr_t attr; |
| 106 int result = pthread_attr_init(&attr); | 108 int result = pthread_attr_init(&attr); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void Monitor::NotifyAll() { | 418 void Monitor::NotifyAll() { |
| 417 // When running with assertions enabled we track the owner. | 419 // When running with assertions enabled we track the owner. |
| 418 ASSERT(IsOwnedByCurrentThread()); | 420 ASSERT(IsOwnedByCurrentThread()); |
| 419 int result = pthread_cond_broadcast(data_.cond()); | 421 int result = pthread_cond_broadcast(data_.cond()); |
| 420 VALIDATE_PTHREAD_RESULT(result); | 422 VALIDATE_PTHREAD_RESULT(result); |
| 421 } | 423 } |
| 422 | 424 |
| 423 } // namespace dart | 425 } // namespace dart |
| 424 | 426 |
| 425 #endif // defined(TARGET_OS_MACOS) | 427 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |