| 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" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 | 9 |
| 10 #include <process.h> // NOLINT | 10 #include <process.h> // NOLINT |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { | 159 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
| 160 ASSERT(key != kUnsetThreadLocalKey); | 160 ASSERT(key != kUnsetThreadLocalKey); |
| 161 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); | 161 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |
| 162 if (!result) { | 162 if (!result) { |
| 163 FATAL1("TlsSetValue failed %d", GetLastError()); | 163 FATAL1("TlsSetValue failed %d", GetLastError()); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 void Thread::InitOnce() { |
| 169 MonitorWaitData::monitor_wait_data_key_ = Thread::CreateThreadLocal(); |
| 170 MonitorData::GetMonitorWaitDataForThread(); |
| 171 } |
| 172 |
| 173 |
| 168 Mutex::Mutex() { | 174 Mutex::Mutex() { |
| 169 // Allocate unnamed semaphore with initial count 1 and max count 1. | 175 // Allocate unnamed semaphore with initial count 1 and max count 1. |
| 170 data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL); | 176 data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL); |
| 171 if (data_.semaphore_ == NULL) { | 177 if (data_.semaphore_ == NULL) { |
| 172 FATAL1("Mutex allocation failed %d", GetLastError()); | 178 FATAL1("Mutex allocation failed %d", GetLastError()); |
| 173 } | 179 } |
| 174 } | 180 } |
| 175 | 181 |
| 176 | 182 |
| 177 Mutex::~Mutex() { | 183 Mutex::~Mutex() { |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // signal. This will be treated as a spurious wake-up and is OK | 438 // signal. This will be treated as a spurious wake-up and is OK |
| 433 // since all uses of monitors should recheck the condition after a | 439 // since all uses of monitors should recheck the condition after a |
| 434 // Wait. | 440 // Wait. |
| 435 data_.SignalAndRemoveAllWaiters(); | 441 data_.SignalAndRemoveAllWaiters(); |
| 436 } | 442 } |
| 437 | 443 |
| 438 } // namespace bin | 444 } // namespace bin |
| 439 } // namespace dart | 445 } // namespace dart |
| 440 | 446 |
| 441 #endif // defined(TARGET_OS_WINDOWS) | 447 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |