Index: runtime/vm/thread_win.cc |
diff --git a/runtime/vm/thread_win.cc b/runtime/vm/thread_win.cc |
index c763babd4de6ef9801e9231d26868ef537a483f6..d4f12353efef1a7c72b966813f424404d59948fe 100644 |
--- a/runtime/vm/thread_win.cc |
+++ b/runtime/vm/thread_win.cc |
@@ -66,106 +66,4 @@ Thread::~Thread() { |
CloseHandle(reinterpret_cast<HANDLE>(data_.thread_handle_)); |
} |
- |
-Mutex::Mutex() { |
- // Allocate unnamed semaphore with initial count 1 and max count 1. |
- data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL); |
- if (data_.semaphore_ == NULL) { |
- FATAL("Mutex allocation failed"); |
- } |
-} |
- |
- |
-Mutex::~Mutex() { |
- CloseHandle(data_.semaphore_); |
-} |
- |
- |
-void Mutex::Lock() { |
- DWORD result = WaitForSingleObject(data_.semaphore_, INFINITE); |
- if (result != WAIT_OBJECT_0) { |
- FATAL("Mutex lock failed"); |
- } |
-} |
- |
- |
-bool Mutex::TryLock() { |
- // Attempt to pass the semaphore but return immediately. |
- DWORD result = WaitForSingleObject(data_.semaphore_, 0); |
- if (result == WAIT_OBJECT_0) { |
- return true; |
- } |
- if (result == WAIT_ABANDONED || result == WAIT_FAILED) { |
- FATAL("Mutex try lock failed"); |
- } |
- ASSERT(result == WAIT_TIMEOUT); |
- return false; |
-} |
- |
- |
-void Mutex::Unlock() { |
- BOOL result = ReleaseSemaphore(data_.semaphore_, 1, NULL); |
- if (result == 0) { |
- FATAL("Mutex unlock failed"); |
- } |
-} |
- |
- |
-Monitor::Monitor() { |
- InitializeCriticalSection(&data_.cs_); |
- InitializeConditionVariable(&data_.cond_); |
-} |
- |
- |
-Monitor::~Monitor() { |
- DeleteCriticalSection(&data_.cs_); |
-} |
- |
- |
-void Monitor::Enter() { |
- EnterCriticalSection(&data_.cs_); |
-} |
- |
- |
-void Monitor::Exit() { |
- LeaveCriticalSection(&data_.cs_); |
-} |
- |
- |
-Monitor::WaitResult Monitor::Wait(int64_t millis) { |
- Monitor::WaitResult retval = kNotified; |
- if (millis == 0) { |
- // Wait forever. |
- BOOL result = SleepConditionVariableCS(&data_.cond_, &data_.cs_, INFINITE); |
- if (result == 0) { |
- FATAL("Monitor::Wait failed"); |
- } |
- } else { |
- BOOL result = SleepConditionVariableCS(&data_.cond_, &data_.cs_, millis); |
- if (result == 0) { |
- DWORD error = GetLastError(); |
- // Windows condition variables should set error to WAIT_TIMEOUT |
- // but occationally sets it to ERROR_TIMEOUT for timeouts. On |
- // Windows 7 it seems to pretty consistently set it to |
- // ERROR_TIMEOUT. |
- if ((error == WAIT_TIMEOUT) || (error == ERROR_TIMEOUT)) { |
- retval = kTimedOut; |
- } else { |
- FATAL("Monitor::Wait failed"); |
- } |
- } |
- } |
- return retval; |
-} |
- |
- |
-void Monitor::Notify() { |
- WakeConditionVariable(&data_.cond_); |
-} |
- |
- |
-void Monitor::NotifyAll() { |
- WakeAllConditionVariable(&data_.cond_); |
-} |
- |
} // namespace dart |