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

Unified Diff: runtime/vm/thread_win.cc

Issue 9196002: Move Mutex and Monitor from vm/ to platform/ (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« runtime/platform/thread_linux.cc ('K') | « runtime/vm/thread_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« runtime/platform/thread_linux.cc ('K') | « runtime/vm/thread_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698