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

Unified Diff: runtime/platform/thread_win.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_win.cc
diff --git a/runtime/platform/thread_win.cc b/runtime/platform/thread_win.cc
index 17d3c59867a6762ceb9b563543faa124d28689ff..3c32bf7cdada118cef4665b73d912c4f4d3b02ff 100644
--- a/runtime/platform/thread_win.cc
+++ b/runtime/platform/thread_win.cc
@@ -62,6 +62,42 @@ int Thread::Start(ThreadStartFunction function, uword parameter) {
}
+ThreadLocalKey Thread::kInvalidThreadLocal = TLS_OUT_OF_INDEXES;
+
+
+ThreadLocalKey Thread::CreateThreadLocal() {
+ ThreadLocalKey key = TlsAlloc();
+ if (key == kInvalidThreadLocal) {
+ FATAL("TlsAlloc failed");
+ }
+ return key;
+}
+
+
+void Thread::DeleteThreadLocal(ThreadLocalKey key) {
+ ASSERT(key != kInvalidThreadLocal);
+ BOOL result = TlsFree(key);
+ if (!result) {
+ FATAL("TlsFree failed");
+ }
+}
+
+
+uword Thread::GetThreadLocal(ThreadLocalKey key) {
+ ASSERT(key != kInvalidThreadLocal);
+ return reinterpret_cast<uword>(TlsGetValue(key));
+}
+
+
+void Thread::SetThreadLocal(ThreadLocalKey key, uword value) {
+ ASSERT(key != kInvalidThreadLocal);
+ BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value));
+ if (!result) {
+ FATAL("TlsSetValue failed");
+ }
+}
+
+
Mutex::Mutex() {
// Allocate unnamed semaphore with initial count 1 and max count 1.
data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL);

Powered by Google App Engine
This is Rietveld 408576698