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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/platform/thread_win.h ('k') | runtime/vm/isolate.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/thread.h" 5 #include "platform/thread.h"
6 6
7 #include <process.h> 7 #include <process.h>
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #ifdef DEBUG 55 #ifdef DEBUG
56 fprintf(stderr, "_beginthreadex error: %d (%s)\n", errno, strerror(errno)); 56 fprintf(stderr, "_beginthreadex error: %d (%s)\n", errno, strerror(errno));
57 #endif 57 #endif
58 return errno; 58 return errno;
59 } 59 }
60 60
61 return 0; 61 return 0;
62 } 62 }
63 63
64 64
65 ThreadLocalKey Thread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
66
67
68 ThreadLocalKey Thread::CreateThreadLocal() {
69 ThreadLocalKey key = TlsAlloc();
70 if (key == kUnsetThreadLocalKey) {
71 FATAL("TlsAlloc failed");
72 }
73 return key;
74 }
75
76
77 void Thread::DeleteThreadLocal(ThreadLocalKey key) {
78 ASSERT(key != kUnsetThreadLocalKey);
79 BOOL result = TlsFree(key);
80 if (!result) {
81 FATAL("TlsFree failed");
82 }
83 }
84
85
86 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) {
87 ASSERT(key != kUnsetThreadLocalKey);
88 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value));
89 if (!result) {
90 FATAL("TlsSetValue failed");
91 }
92 }
93
94
65 Mutex::Mutex() { 95 Mutex::Mutex() {
66 // Allocate unnamed semaphore with initial count 1 and max count 1. 96 // Allocate unnamed semaphore with initial count 1 and max count 1.
67 data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL); 97 data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL);
68 if (data_.semaphore_ == NULL) { 98 if (data_.semaphore_ == NULL) {
69 FATAL("Mutex allocation failed"); 99 FATAL("Mutex allocation failed");
70 } 100 }
71 } 101 }
72 102
73 103
74 Mutex::~Mutex() { 104 Mutex::~Mutex() {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void Monitor::Notify() { 187 void Monitor::Notify() {
158 WakeConditionVariable(&data_.cond_); 188 WakeConditionVariable(&data_.cond_);
159 } 189 }
160 190
161 191
162 void Monitor::NotifyAll() { 192 void Monitor::NotifyAll() {
163 WakeAllConditionVariable(&data_.cond_); 193 WakeAllConditionVariable(&data_.cond_);
164 } 194 }
165 195
166 } // namespace dart 196 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/platform/thread_win.h ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698