Index: src/platform-macos.cc |
=================================================================== |
--- src/platform-macos.cc (revision 1525) |
+++ src/platform-macos.cc (working copy) |
@@ -565,6 +565,8 @@ |
// platform is not needed here. |
void Wait() { semaphore_wait(semaphore_); } |
+ bool Wait(int timeout); |
+ |
void Signal() { semaphore_signal(semaphore_); } |
private: |
@@ -572,6 +574,14 @@ |
}; |
+bool MacOSSemaphore::Wait(int timeout) { |
+ mach_timespec_t ts; |
+ ts.tv_sec = timeout / 1000000; |
+ ts.tv_nsec = (timeout % 1000000) * 1000; |
+ return semaphore_timedwait(semaphore_, ts) != KERN_OPERATION_TIMED_OUT; |
+} |
+ |
+ |
Semaphore* OS::CreateSemaphore(int count) { |
return new MacOSSemaphore(count); |
} |