| OLD | NEW |
| 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" // NOLINT | 5 #include "platform/globals.h" // NOLINT |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/os_thread.h" | 9 #include "vm/os_thread.h" |
| 10 | 10 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 ASSERT(IsOwnedByCurrentThread()); | 269 ASSERT(IsOwnedByCurrentThread()); |
| 270 owner_ = OSThread::kInvalidThreadId; | 270 owner_ = OSThread::kInvalidThreadId; |
| 271 #endif // defined(DEBUG) | 271 #endif // defined(DEBUG) |
| 272 BOOL result = ReleaseSemaphore(data_.semaphore_, 1, NULL); | 272 BOOL result = ReleaseSemaphore(data_.semaphore_, 1, NULL); |
| 273 if (result == 0) { | 273 if (result == 0) { |
| 274 FATAL1("Mutex unlock failed %d", GetLastError()); | 274 FATAL1("Mutex unlock failed %d", GetLastError()); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 | 278 |
| 279 ThreadLocalKey MonitorWaitData::monitor_wait_data_key_ = | 279 ThreadLocalKey MonitorWaitData::monitor_wait_data_key_ = kUnsetThreadLocalKey; |
| 280 OSThread::kUnsetThreadLocalKey; | |
| 281 | 280 |
| 282 | 281 |
| 283 Monitor::Monitor() { | 282 Monitor::Monitor() { |
| 284 InitializeCriticalSection(&data_.cs_); | 283 InitializeCriticalSection(&data_.cs_); |
| 285 InitializeCriticalSection(&data_.waiters_cs_); | 284 InitializeCriticalSection(&data_.waiters_cs_); |
| 286 data_.waiters_head_ = NULL; | 285 data_.waiters_head_ = NULL; |
| 287 data_.waiters_tail_ = NULL; | 286 data_.waiters_tail_ = NULL; |
| 288 | 287 |
| 289 #if defined(DEBUG) | 288 #if defined(DEBUG) |
| 290 // When running with assertions enabled we track the owner. | 289 // When running with assertions enabled we track the owner. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 320 // When running with assertions enabled we track the owner. | 319 // When running with assertions enabled we track the owner. |
| 321 ASSERT(IsOwnedByCurrentThread()); | 320 ASSERT(IsOwnedByCurrentThread()); |
| 322 owner_ = OSThread::kInvalidThreadId; | 321 owner_ = OSThread::kInvalidThreadId; |
| 323 #endif // defined(DEBUG) | 322 #endif // defined(DEBUG) |
| 324 | 323 |
| 325 LeaveCriticalSection(&data_.cs_); | 324 LeaveCriticalSection(&data_.cs_); |
| 326 } | 325 } |
| 327 | 326 |
| 328 | 327 |
| 329 void MonitorWaitData::ThreadExit() { | 328 void MonitorWaitData::ThreadExit() { |
| 330 if (MonitorWaitData::monitor_wait_data_key_ != | 329 if (MonitorWaitData::monitor_wait_data_key_ != kUnsetThreadLocalKey) { |
| 331 OSThread::kUnsetThreadLocalKey) { | |
| 332 uword raw_wait_data = | 330 uword raw_wait_data = |
| 333 OSThread::GetThreadLocal(MonitorWaitData::monitor_wait_data_key_); | 331 OSThread::GetThreadLocal(MonitorWaitData::monitor_wait_data_key_); |
| 334 // Clear in case this is called a second time. | 332 // Clear in case this is called a second time. |
| 335 OSThread::SetThreadLocal(MonitorWaitData::monitor_wait_data_key_, 0); | 333 OSThread::SetThreadLocal(MonitorWaitData::monitor_wait_data_key_, 0); |
| 336 if (raw_wait_data != 0) { | 334 if (raw_wait_data != 0) { |
| 337 MonitorWaitData* wait_data = | 335 MonitorWaitData* wait_data = |
| 338 reinterpret_cast<MonitorWaitData*>(raw_wait_data); | 336 reinterpret_cast<MonitorWaitData*>(raw_wait_data); |
| 339 delete wait_data; | 337 delete wait_data; |
| 340 } | 338 } |
| 341 } | 339 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 427 } |
| 430 current = next; | 428 current = next; |
| 431 } | 429 } |
| 432 LeaveCriticalSection(&waiters_cs_); | 430 LeaveCriticalSection(&waiters_cs_); |
| 433 } | 431 } |
| 434 | 432 |
| 435 | 433 |
| 436 MonitorWaitData* MonitorData::GetMonitorWaitDataForThread() { | 434 MonitorWaitData* MonitorData::GetMonitorWaitDataForThread() { |
| 437 // Ensure that the thread local key for monitor wait data objects is | 435 // Ensure that the thread local key for monitor wait data objects is |
| 438 // initialized. | 436 // initialized. |
| 439 ASSERT(MonitorWaitData::monitor_wait_data_key_ != | 437 ASSERT(MonitorWaitData::monitor_wait_data_key_ != kUnsetThreadLocalKey); |
| 440 OSThread::kUnsetThreadLocalKey); | |
| 441 | 438 |
| 442 // Get the MonitorWaitData object containing the event for this | 439 // Get the MonitorWaitData object containing the event for this |
| 443 // thread from thread local storage. Create it if it does not exist. | 440 // thread from thread local storage. Create it if it does not exist. |
| 444 uword raw_wait_data = | 441 uword raw_wait_data = |
| 445 OSThread::GetThreadLocal(MonitorWaitData::monitor_wait_data_key_); | 442 OSThread::GetThreadLocal(MonitorWaitData::monitor_wait_data_key_); |
| 446 MonitorWaitData* wait_data = NULL; | 443 MonitorWaitData* wait_data = NULL; |
| 447 if (raw_wait_data == 0) { | 444 if (raw_wait_data == 0) { |
| 448 HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL); | 445 HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL); |
| 449 wait_data = new MonitorWaitData(event); | 446 wait_data = new MonitorWaitData(event); |
| 450 OSThread::SetThreadLocal(MonitorWaitData::monitor_wait_data_key_, | 447 OSThread::SetThreadLocal(MonitorWaitData::monitor_wait_data_key_, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 #pragma data_seg(".CRT$XLB") | 696 #pragma data_seg(".CRT$XLB") |
| 700 PIMAGE_TLS_CALLBACK p_thread_callback_dart = OnDartThreadExit; | 697 PIMAGE_TLS_CALLBACK p_thread_callback_dart = OnDartThreadExit; |
| 701 | 698 |
| 702 // Reset the default section. | 699 // Reset the default section. |
| 703 #pragma data_seg() | 700 #pragma data_seg() |
| 704 | 701 |
| 705 #endif // _WIN64 | 702 #endif // _WIN64 |
| 706 } // extern "C" | 703 } // extern "C" |
| 707 | 704 |
| 708 #endif // defined(TARGET_OS_WINDOWS) | 705 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |