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

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

Issue 1134003005: Automatic thread cleanup on non-Windows platforms. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/os_thread_linux.cc ('k') | runtime/vm/os_thread_win.cc » ('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_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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 RETURN_ON_PTHREAD_FAILURE(result); 102 RETURN_ON_PTHREAD_FAILURE(result);
103 103
104 return 0; 104 return 0;
105 } 105 }
106 106
107 107
108 ThreadLocalKey OSThread::kUnsetThreadLocalKey = 108 ThreadLocalKey OSThread::kUnsetThreadLocalKey =
109 static_cast<pthread_key_t>(-1); 109 static_cast<pthread_key_t>(-1);
110 ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL); 110 ThreadId OSThread::kInvalidThreadId = reinterpret_cast<ThreadId>(NULL);
111 111
112 ThreadLocalKey OSThread::CreateThreadLocal() { 112 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
113 pthread_key_t key = kUnsetThreadLocalKey; 113 pthread_key_t key = kUnsetThreadLocalKey;
114 int result = pthread_key_create(&key, NULL); 114 int result = pthread_key_create(&key, destructor);
115 VALIDATE_PTHREAD_RESULT(result); 115 VALIDATE_PTHREAD_RESULT(result);
116 ASSERT(key != kUnsetThreadLocalKey); 116 ASSERT(key != kUnsetThreadLocalKey);
117 return key; 117 return key;
118 } 118 }
119 119
120 120
121 void OSThread::DeleteThreadLocal(ThreadLocalKey key) { 121 void OSThread::DeleteThreadLocal(ThreadLocalKey key) {
122 ASSERT(key != kUnsetThreadLocalKey); 122 ASSERT(key != kUnsetThreadLocalKey);
123 int result = pthread_key_delete(key); 123 int result = pthread_key_delete(key);
124 VALIDATE_PTHREAD_RESULT(result); 124 VALIDATE_PTHREAD_RESULT(result);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 void Monitor::NotifyAll() { 348 void Monitor::NotifyAll() {
349 // TODO(iposva): Do we need to track lock owners? 349 // TODO(iposva): Do we need to track lock owners?
350 int result = pthread_cond_broadcast(data_.cond()); 350 int result = pthread_cond_broadcast(data_.cond());
351 VALIDATE_PTHREAD_RESULT(result); 351 VALIDATE_PTHREAD_RESULT(result);
352 } 352 }
353 353
354 } // namespace dart 354 } // namespace dart
355 355
356 #endif // defined(TARGET_OS_MACOS) 356 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_linux.cc ('k') | runtime/vm/os_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698