Index: util/synchronization/semaphore.cc |
diff --git a/util/synchronization/semaphore.cc b/util/synchronization/semaphore.cc |
index d513fa0dd43981acc72b1ff155fa2d1e77616388..789ac1e9e0f65421f7f31c550066b2d72a0a8e61 100644 |
--- a/util/synchronization/semaphore.cc |
+++ b/util/synchronization/semaphore.cc |
@@ -14,6 +14,8 @@ |
#include "util/synchronization/semaphore.h" |
+#include <limits> |
+ |
#include "base/logging.h" |
#include "base/posix/eintr_wrapper.h" |
scottmg
2014/12/17 22:58:15
I didn't realize before, but this guards its entir
|
@@ -38,6 +40,28 @@ void Semaphore::Signal() { |
dispatch_semaphore_signal(semaphore_); |
} |
+#elif defined(OS_WIN) |
+ |
+Semaphore::Semaphore(int value) |
+ : semaphore_(CreateSemaphore(nullptr, |
+ value, |
+ std::numeric_limits<LONG>::max(), |
+ nullptr)) { |
+ PCHECK(semaphore_) << "CreateSemaphore"; |
+} |
+ |
+Semaphore::~Semaphore() { |
+ PCHECK(CloseHandle(semaphore_)); |
+} |
+ |
+void Semaphore::Wait() { |
+ CHECK_EQ(WaitForSingleObject(semaphore_, INFINITE), WAIT_OBJECT_0); |
Mark Mentovai
2014/12/18 14:38:47
PCHECK this and ReleaseSemaphore()?
scottmg
2014/12/18 17:07:02
Done.
|
+} |
+ |
+void Semaphore::Signal() { |
+ CHECK(ReleaseSemaphore(semaphore_, 1, nullptr)); |
+} |
+ |
#else |
Semaphore::Semaphore(int value) { |