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

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

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge Created 5 years, 3 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
« no previous file with comments | « runtime/vm/os_thread_android.h ('k') | runtime/vm/os_thread_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 return NULL; 95 return NULL;
96 } 96 }
97 97
98 98
99 int OSThread::Start(ThreadStartFunction function, uword parameter) { 99 int OSThread::Start(ThreadStartFunction function, uword parameter) {
100 pthread_attr_t attr; 100 pthread_attr_t attr;
101 int result = pthread_attr_init(&attr); 101 int result = pthread_attr_init(&attr);
102 RETURN_ON_PTHREAD_FAILURE(result); 102 RETURN_ON_PTHREAD_FAILURE(result);
103 103
104 result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
105 RETURN_ON_PTHREAD_FAILURE(result);
106
107 result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize()); 104 result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize());
108 RETURN_ON_PTHREAD_FAILURE(result); 105 RETURN_ON_PTHREAD_FAILURE(result);
109 106
110 ThreadStartData* data = new ThreadStartData(function, parameter); 107 ThreadStartData* data = new ThreadStartData(function, parameter);
111 108
112 pthread_t tid; 109 pthread_t tid;
113 result = pthread_create(&tid, &attr, ThreadStart, data); 110 result = pthread_create(&tid, &attr, ThreadStart, data);
114 RETURN_ON_PTHREAD_FAILURE(result); 111 RETURN_ON_PTHREAD_FAILURE(result);
115 112
116 result = pthread_attr_destroy(&attr); 113 result = pthread_attr_destroy(&attr);
117 RETURN_ON_PTHREAD_FAILURE(result); 114 RETURN_ON_PTHREAD_FAILURE(result);
118 115
119 return 0; 116 return 0;
120 } 117 }
121 118
122 119
123 ThreadLocalKey OSThread::kUnsetThreadLocalKey = 120 ThreadLocalKey OSThread::kUnsetThreadLocalKey =
124 static_cast<pthread_key_t>(-1); 121 static_cast<pthread_key_t>(-1);
125 ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0); 122 ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0);
123 ThreadJoinId OSThread::kInvalidThreadJoinId = static_cast<ThreadJoinId>(0);
126 124
127 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { 125 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
128 pthread_key_t key = kUnsetThreadLocalKey; 126 pthread_key_t key = kUnsetThreadLocalKey;
129 int result = pthread_key_create(&key, destructor); 127 int result = pthread_key_create(&key, destructor);
130 VALIDATE_PTHREAD_RESULT(result); 128 VALIDATE_PTHREAD_RESULT(result);
131 ASSERT(key != kUnsetThreadLocalKey); 129 ASSERT(key != kUnsetThreadLocalKey);
132 return key; 130 return key;
133 } 131 }
134 132
135 133
(...skipping 15 matching lines...) Expand all
151 const int kStackSize = (128 * kWordSize * KB); 149 const int kStackSize = (128 * kWordSize * KB);
152 return kStackSize; 150 return kStackSize;
153 } 151 }
154 152
155 153
156 ThreadId OSThread::GetCurrentThreadId() { 154 ThreadId OSThread::GetCurrentThreadId() {
157 return gettid(); 155 return gettid();
158 } 156 }
159 157
160 158
161 bool OSThread::Join(ThreadId id) { 159 ThreadJoinId OSThread::GetCurrentThreadJoinId() {
162 return false; 160 return pthread_self();
163 } 161 }
164 162
165 163
164 void OSThread::Join(ThreadJoinId id) {
165 ASSERT(pthread_join(id, NULL) == 0);
166 }
167
168
166 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { 169 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) {
167 ASSERT(sizeof(id) == sizeof(intptr_t)); 170 ASSERT(sizeof(id) == sizeof(intptr_t));
168 return static_cast<intptr_t>(id); 171 return static_cast<intptr_t>(id);
169 } 172 }
170 173
171 174
172 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { 175 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) {
173 return static_cast<ThreadId>(id); 176 return static_cast<ThreadId>(id);
174 } 177 }
175 178
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 354
352 void Monitor::NotifyAll() { 355 void Monitor::NotifyAll() {
353 // TODO(iposva): Do we need to track lock owners? 356 // TODO(iposva): Do we need to track lock owners?
354 int result = pthread_cond_broadcast(data_.cond()); 357 int result = pthread_cond_broadcast(data_.cond());
355 VALIDATE_PTHREAD_RESULT(result); 358 VALIDATE_PTHREAD_RESULT(result);
356 } 359 }
357 360
358 } // namespace dart 361 } // namespace dart
359 362
360 #endif // defined(TARGET_OS_ANDROID) 363 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_android.h ('k') | runtime/vm/os_thread_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698