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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // exits. | 88 // exits. |
89 static void* ThreadStart(void* data_ptr) { | 89 static void* ThreadStart(void* data_ptr) { |
90 ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr); | 90 ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr); |
91 | 91 |
92 const char* name = data->name(); | 92 const char* name = data->name(); |
93 OSThread::ThreadStartFunction function = data->function(); | 93 OSThread::ThreadStartFunction function = data->function(); |
94 uword parameter = data->parameter(); | 94 uword parameter = data->parameter(); |
95 delete data; | 95 delete data; |
96 | 96 |
97 // Create new OSThread object and set as TLS for new thread. | 97 // Create new OSThread object and set as TLS for new thread. |
98 OSThread* thread = new OSThread(); | 98 OSThread* thread = OSThread::CreateOSThread(); |
99 OSThread::SetCurrent(thread); | 99 if (thread != NULL) { |
100 thread->set_name(name); | 100 OSThread::SetCurrent(thread); |
| 101 thread->set_name(name); |
101 | 102 |
102 // Call the supplied thread start function handing it its parameters. | 103 // Call the supplied thread start function handing it its parameters. |
103 function(parameter); | 104 function(parameter); |
| 105 } |
104 | 106 |
105 return NULL; | 107 return NULL; |
106 } | 108 } |
107 | 109 |
108 | 110 |
109 int OSThread::Start(const char* name, | 111 int OSThread::Start(const char* name, |
110 ThreadStartFunction function, | 112 ThreadStartFunction function, |
111 uword parameter) { | 113 uword parameter) { |
112 pthread_attr_t attr; | 114 pthread_attr_t attr; |
113 int result = pthread_attr_init(&attr); | 115 int result = pthread_attr_init(&attr); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 void Monitor::NotifyAll() { | 409 void Monitor::NotifyAll() { |
408 // When running with assertions enabled we track the owner. | 410 // When running with assertions enabled we track the owner. |
409 ASSERT(IsOwnedByCurrentThread()); | 411 ASSERT(IsOwnedByCurrentThread()); |
410 int result = pthread_cond_broadcast(data_.cond()); | 412 int result = pthread_cond_broadcast(data_.cond()); |
411 VALIDATE_PTHREAD_RESULT(result); | 413 VALIDATE_PTHREAD_RESULT(result); |
412 } | 414 } |
413 | 415 |
414 } // namespace dart | 416 } // namespace dart |
415 | 417 |
416 #endif // defined(TARGET_OS_ANDROID) | 418 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |