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

Unified Diff: runtime/platform/thread_macos.cc

Issue 9328042: Move the thread local functions to the Thread class in runtime/platform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reverted unintentional change Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: runtime/platform/thread_macos.cc
diff --git a/runtime/platform/thread_macos.cc b/runtime/platform/thread_macos.cc
index 6fa80ce738f5a31f5bd92d6e4ff13d07e499ffdc..19dd9c8e7c99c474c2ba95d1990fa514857b7b2c 100644
--- a/runtime/platform/thread_macos.cc
+++ b/runtime/platform/thread_macos.cc
@@ -87,6 +87,37 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
}
+ThreadLocalKey Thread::kInvalidThreadLocal = static_cast<pthread_key_t>(-1);
+
+
+ThreadLocalKey Thread::CreateThreadLocal() {
+ pthread_key_t key = kInvalidThreadLocal;
+ int result = pthread_key_create(&key, NULL);
siva 2012/02/06 19:29:37 ASSERT(key != kInvalidThreadLocal);
Søren Gjesse 2012/02/07 09:13:59 Done.
+ VALIDATE_PTHREAD_RESULT(result);
+ return key;
+}
+
+
+void Thread::DeleteThreadLocal(ThreadLocalKey key) {
+ ASSERT(key != kInvalidThreadLocal);
+ int result = pthread_key_delete(key);
+ VALIDATE_PTHREAD_RESULT(result);
+}
+
+
+uword Thread::GetThreadLocal(ThreadLocalKey key) {
+ ASSERT(key != kInvalidThreadLocal);
+ return reinterpret_cast<uword>(pthread_getspecific(key));
+}
siva 2012/02/06 19:29:37 Inline this method in the header so that there is
Søren Gjesse 2012/02/07 09:13:59 Done.
+
+
+void Thread::SetThreadLocal(ThreadLocalKey key, uword value) {
+ ASSERT(key != kInvalidThreadLocal);
+ int result = pthread_setspecific(key, reinterpret_cast<void*>(value));
+ VALIDATE_PTHREAD_RESULT(result);
+}
+
+
Mutex::Mutex() {
pthread_mutexattr_t attr;
int result = pthread_mutexattr_init(&attr);

Powered by Google App Engine
This is Rietveld 408576698