OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/platform/semaphore.h" | 5 #include "src/base/platform/semaphore.h" |
6 | 6 |
7 #if V8_OS_MACOSX | 7 #if V8_OS_MACOSX |
8 #include <mach/mach_init.h> | 8 #include <mach/mach_init.h> |
9 #include <mach/task.h> | 9 #include <mach/task.h> |
10 #endif | 10 #endif |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 Semaphore::~Semaphore() { | 95 Semaphore::~Semaphore() { |
96 int result = sem_destroy(&native_handle_); | 96 int result = sem_destroy(&native_handle_); |
97 DCHECK_EQ(0, result); | 97 DCHECK_EQ(0, result); |
98 USE(result); | 98 USE(result); |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 void Semaphore::Signal() { | 102 void Semaphore::Signal() { |
103 int result = sem_post(&native_handle_); | 103 int result = sem_post(&native_handle_); |
104 CHECK_EQ(0, result); | 104 if (result != 0) { |
| 105 V8_Fatal(__FILE__, __LINE__, "Semaphore signal failure: %d\n", errno); |
| 106 } |
105 } | 107 } |
106 | 108 |
107 | 109 |
108 void Semaphore::Wait() { | 110 void Semaphore::Wait() { |
109 while (true) { | 111 while (true) { |
110 int result = sem_wait(&native_handle_); | 112 int result = sem_wait(&native_handle_); |
111 if (result == 0) return; // Semaphore was signalled. | 113 if (result == 0) return; // Semaphore was signalled. |
112 // Signal caused spurious wakeup. | 114 // Signal caused spurious wakeup. |
113 DCHECK_EQ(-1, result); | 115 DCHECK_EQ(-1, result); |
114 DCHECK_EQ(EINTR, errno); | 116 DCHECK_EQ(EINTR, errno); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 DCHECK(result == WAIT_OBJECT_0); | 208 DCHECK(result == WAIT_OBJECT_0); |
207 return true; | 209 return true; |
208 } | 210 } |
209 } | 211 } |
210 } | 212 } |
211 | 213 |
212 #endif // V8_OS_MACOSX | 214 #endif // V8_OS_MACOSX |
213 | 215 |
214 } // namespace base | 216 } // namespace base |
215 } // namespace v8 | 217 } // namespace v8 |
OLD | NEW |