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

Unified Diff: util/synchronization/semaphore.cc

Issue 797173003: win: implement Semaphore (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years 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
« no previous file with comments | « util/synchronization/semaphore.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « util/synchronization/semaphore.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698