| Index: util/synchronization/semaphore.cc
|
| diff --git a/util/synchronization/semaphore.cc b/util/synchronization/semaphore.cc
|
| index d513fa0dd43981acc72b1ff155fa2d1e77616388..5f0a206adaa48fdf48e41221f35f2662a91053de 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"
|
|
|
| @@ -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() {
|
| + PCHECK(WaitForSingleObject(semaphore_, INFINITE) == WAIT_OBJECT_0);
|
| +}
|
| +
|
| +void Semaphore::Signal() {
|
| + PCHECK(ReleaseSemaphore(semaphore_, 1, nullptr));
|
| +}
|
| +
|
| #else
|
|
|
| Semaphore::Semaphore(int value) {
|
|
|