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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 Semaphore::~Semaphore() { | 88 Semaphore::~Semaphore() { |
89 int result = sem_destroy(&native_handle_); | 89 int result = sem_destroy(&native_handle_); |
90 DCHECK_EQ(0, result); | 90 DCHECK_EQ(0, result); |
91 USE(result); | 91 USE(result); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 void Semaphore::Signal() { | 95 void Semaphore::Signal() { |
96 int result = sem_post(&native_handle_); | 96 int result = sem_post(&native_handle_); |
97 DCHECK_EQ(0, result); | 97 CHECK_EQ(0, result); |
98 USE(result); | |
99 } | 98 } |
100 | 99 |
101 | 100 |
102 void Semaphore::Wait() { | 101 void Semaphore::Wait() { |
103 while (true) { | 102 while (true) { |
104 int result = sem_wait(&native_handle_); | 103 int result = sem_wait(&native_handle_); |
105 if (result == 0) return; // Semaphore was signalled. | 104 if (result == 0) return; // Semaphore was signalled. |
106 // Signal caused spurious wakeup. | 105 // Signal caused spurious wakeup. |
107 DCHECK_EQ(-1, result); | 106 DCHECK_EQ(-1, result); |
108 DCHECK_EQ(EINTR, errno); | 107 DCHECK_EQ(EINTR, errno); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 DCHECK(result == WAIT_OBJECT_0); | 199 DCHECK(result == WAIT_OBJECT_0); |
201 return true; | 200 return true; |
202 } | 201 } |
203 } | 202 } |
204 } | 203 } |
205 | 204 |
206 #endif // V8_OS_MACOSX | 205 #endif // V8_OS_MACOSX |
207 | 206 |
208 } // namespace base | 207 } // namespace base |
209 } // namespace v8 | 208 } // namespace v8 |
OLD | NEW |