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/condition-variable.h" | 5 #include "src/base/platform/condition-variable.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "src/base/platform/time.h" | 10 #include "src/base/platform/time.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 | 258 |
259 void ConditionVariable::Wait(Mutex* mutex) { | 259 void ConditionVariable::Wait(Mutex* mutex) { |
260 // Create and setup the wait event. | 260 // Create and setup the wait event. |
261 Event* event = native_handle_.Pre(); | 261 Event* event = native_handle_.Pre(); |
262 | 262 |
263 // Release the user mutex. | 263 // Release the user mutex. |
264 mutex->Unlock(); | 264 mutex->Unlock(); |
265 | 265 |
266 // Wait on the wait event. | 266 // Wait on the wait event. |
267 while (!event->WaitFor(INFINITE)) | 267 while (!event->WaitFor(INFINITE)) { |
268 ; | 268 } |
269 | 269 |
270 // Reaquire the user mutex. | 270 // Reaquire the user mutex. |
271 mutex->Lock(); | 271 mutex->Lock(); |
272 | 272 |
273 // Release the wait event (we must have been notified). | 273 // Release the wait event (we must have been notified). |
274 DCHECK(event->notified_); | 274 DCHECK(event->notified_); |
275 native_handle_.Post(event, true); | 275 native_handle_.Post(event, true); |
276 } | 276 } |
277 | 277 |
278 | 278 |
(...skipping 28 matching lines...) Expand all Loading... |
307 // Release the wait event. | 307 // Release the wait event. |
308 DCHECK(!result || event->notified_); | 308 DCHECK(!result || event->notified_); |
309 native_handle_.Post(event, result); | 309 native_handle_.Post(event, result); |
310 | 310 |
311 return result; | 311 return result; |
312 } | 312 } |
313 | 313 |
314 #endif // V8_OS_POSIX | 314 #endif // V8_OS_POSIX |
315 | 315 |
316 } } // namespace v8::base | 316 } } // namespace v8::base |
OLD | NEW |