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