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

Unified Diff: src/platform-macos.cc

Issue 10867009: platform: fix semaphore on mac os Base URL: gh:v8/v8@master
Patch Set: the last lint fix Created 8 years, 4 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
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index a937ed3a5c12c580a2c26e36611e6070aa2ee2dc..50f909888ff7ef2d3d5d1d732a2d6859c3544161 100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -682,17 +682,28 @@ Mutex* OS::CreateMutex() {
class MacOSSemaphore : public Semaphore {
public:
explicit MacOSSemaphore(int count) {
- semaphore_create(mach_task_self(), &semaphore_, SYNC_POLICY_FIFO, count);
+ int r;
+ r = semaphore_create(mach_task_self(),
+ &semaphore_,
+ SYNC_POLICY_FIFO,
+ count);
+ ASSERT(r == KERN_SUCCESS);
}
~MacOSSemaphore() {
- semaphore_destroy(mach_task_self(), semaphore_);
+ int r;
+ r = semaphore_destroy(mach_task_self(), semaphore_);
+ ASSERT(r == KERN_SUCCESS);
}
- // The MacOS mach semaphore documentation claims it does not have spurious
- // wakeups, the way pthreads semaphores do. So the code from the linux
- // platform is not needed here.
- void Wait() { semaphore_wait(semaphore_); }
+ void Wait() {
+ int r;
+ do {
+ r = semaphore_wait(semaphore_);
+ } while (r == KERN_ABORTED);
+
+ ASSERT(r == KERN_SUCCESS);
Erik Corry 2012/08/23 09:23:39 I will move this up into the loop and assert that
+ }
bool Wait(int timeout);
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698