Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: runtime/vm/os_thread_linux.cc

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 return NULL; 96 return NULL;
97 } 97 }
98 98
99 99
100 int OSThread::Start(ThreadStartFunction function, uword parameter) { 100 int OSThread::Start(ThreadStartFunction function, uword parameter) {
101 pthread_attr_t attr; 101 pthread_attr_t attr;
102 int result = pthread_attr_init(&attr); 102 int result = pthread_attr_init(&attr);
103 RETURN_ON_PTHREAD_FAILURE(result); 103 RETURN_ON_PTHREAD_FAILURE(result);
104 104
105 result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
106 RETURN_ON_PTHREAD_FAILURE(result);
107
108 result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize()); 105 result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize());
109 RETURN_ON_PTHREAD_FAILURE(result); 106 RETURN_ON_PTHREAD_FAILURE(result);
110 107
111 ThreadStartData* data = new ThreadStartData(function, parameter); 108 ThreadStartData* data = new ThreadStartData(function, parameter);
112 109
113 pthread_t tid; 110 pthread_t tid;
114 result = pthread_create(&tid, &attr, ThreadStart, data); 111 result = pthread_create(&tid, &attr, ThreadStart, data);
115 RETURN_ON_PTHREAD_FAILURE(result); 112 RETURN_ON_PTHREAD_FAILURE(result);
116 113
117 result = pthread_attr_destroy(&attr); 114 result = pthread_attr_destroy(&attr);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return kStackSize; 150 return kStackSize;
154 } 151 }
155 152
156 153
157 ThreadId OSThread::GetCurrentThreadId() { 154 ThreadId OSThread::GetCurrentThreadId() {
158 return pthread_self(); 155 return pthread_self();
159 } 156 }
160 157
161 158
162 bool OSThread::Join(ThreadId id) { 159 bool OSThread::Join(ThreadId id) {
163 return false; 160 return pthread_join(id, NULL) == 0;
164 } 161 }
165 162
166 163
167 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { 164 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) {
168 ASSERT(sizeof(id) == sizeof(intptr_t)); 165 ASSERT(sizeof(id) == sizeof(intptr_t));
169 return static_cast<intptr_t>(id); 166 return static_cast<intptr_t>(id);
170 } 167 }
171 168
172 169
173 bool OSThread::Compare(ThreadId a, ThreadId b) { 170 bool OSThread::Compare(ThreadId a, ThreadId b) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 347
351 void Monitor::NotifyAll() { 348 void Monitor::NotifyAll() {
352 // TODO(iposva): Do we need to track lock owners? 349 // TODO(iposva): Do we need to track lock owners?
353 int result = pthread_cond_broadcast(data_.cond()); 350 int result = pthread_cond_broadcast(data_.cond());
354 VALIDATE_PTHREAD_RESULT(result); 351 VALIDATE_PTHREAD_RESULT(result);
355 } 352 }
356 353
357 } // namespace dart 354 } // namespace dart
358 355
359 #endif // defined(TARGET_OS_LINUX) 356 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698