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

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: Addressed review comments from asiva@ 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
« no previous file with comments | « runtime/platform/thread_macos.h ('k') | runtime/platform/thread_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/thread_macos.cc
diff --git a/runtime/platform/thread_macos.cc b/runtime/platform/thread_macos.cc
index 6fa80ce738f5a31f5bd92d6e4ff13d07e499ffdc..4dd208bac3ffcc8b83fb1573813fce9ea2c01991 100644
--- a/runtime/platform/thread_macos.cc
+++ b/runtime/platform/thread_macos.cc
@@ -87,6 +87,32 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
}
+ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
+
+
+ThreadLocalKey Thread::CreateThreadLocal() {
+ pthread_key_t key = kUnsetThreadLocalKey;
+ int result = pthread_key_create(&key, NULL);
+ VALIDATE_PTHREAD_RESULT(result);
+ ASSERT(key != kUnsetThreadLocalKey);
+ return key;
+}
+
+
+void Thread::DeleteThreadLocal(ThreadLocalKey key) {
+ ASSERT(key != kUnsetThreadLocalKey);
+ int result = pthread_key_delete(key);
+ VALIDATE_PTHREAD_RESULT(result);
+}
+
+
+void Thread::SetThreadLocal(ThreadLocalKey key, uword value) {
+ ASSERT(key != kUnsetThreadLocalKey);
+ 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);
« no previous file with comments | « runtime/platform/thread_macos.h ('k') | runtime/platform/thread_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698