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

Side by Side Diff: runtime/platform/thread_win.cc

Issue 13470006: Only lookup and delete the monitor wait data if it was allocated. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « no previous file | tests/standalone/standalone.status » ('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" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "platform/thread.h" 8 #include "platform/thread.h"
9 9
10 #include <process.h> // NOLINT 10 #include <process.h> // NOLINT
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 EnterCriticalSection(&data_.cs_); 167 EnterCriticalSection(&data_.cs_);
168 } 168 }
169 169
170 170
171 void Monitor::Exit() { 171 void Monitor::Exit() {
172 LeaveCriticalSection(&data_.cs_); 172 LeaveCriticalSection(&data_.cs_);
173 } 173 }
174 174
175 175
176 void MonitorWaitData::ThreadExit() { 176 void MonitorWaitData::ThreadExit() {
177 uword raw_wait_data = 177 if (MonitorWaitData::monitor_wait_data_key_ !=
178 Thread::GetThreadLocal(MonitorWaitData::monitor_wait_data_key_); 178 Thread::kUnsetThreadLocalKey) {
179 if (raw_wait_data != 0) { 179 uword raw_wait_data =
180 MonitorWaitData* wait_data = 180 Thread::GetThreadLocal(MonitorWaitData::monitor_wait_data_key_);
181 reinterpret_cast<MonitorWaitData*>(raw_wait_data); 181 if (raw_wait_data != 0) {
182 delete wait_data; 182 MonitorWaitData* wait_data =
183 reinterpret_cast<MonitorWaitData*>(raw_wait_data);
184 delete wait_data;
185 }
183 } 186 }
184 } 187 }
185 188
186 189
187 void MonitorData::AddWaiter(MonitorWaitData* wait_data) { 190 void MonitorData::AddWaiter(MonitorWaitData* wait_data) {
188 // Add the MonitorWaitData object to the list of objects waiting for 191 // Add the MonitorWaitData object to the list of objects waiting for
189 // this monitor. 192 // this monitor.
190 EnterCriticalSection(&waiters_cs_); 193 EnterCriticalSection(&waiters_cs_);
191 if (waiters_tail_ == NULL) { 194 if (waiters_tail_ == NULL) {
192 ASSERT(waiters_head_ == NULL); 195 ASSERT(waiters_head_ == NULL);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // timeout before we signal it, that object will get an extra 348 // timeout before we signal it, that object will get an extra
346 // signal. This will be treated as a spurious wake-up and is OK 349 // signal. This will be treated as a spurious wake-up and is OK
347 // since all uses of monitors should recheck the condition after a 350 // since all uses of monitors should recheck the condition after a
348 // Wait. 351 // Wait.
349 data_.SignalAndRemoveAllWaiters(); 352 data_.SignalAndRemoveAllWaiters();
350 } 353 }
351 354
352 } // namespace dart 355 } // namespace dart
353 356
354 #endif // defined(TARGET_OS_WINDOWS) 357 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698