| 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 18 matching lines...) Expand all Loading... |
| 29 result = pthread_condattr_destroy(&attr); | 29 result = pthread_condattr_destroy(&attr); |
| 30 #else | 30 #else |
| 31 int result = pthread_cond_init(&native_handle_, NULL); | 31 int result = pthread_cond_init(&native_handle_, NULL); |
| 32 #endif | 32 #endif |
| 33 DCHECK_EQ(0, result); | 33 DCHECK_EQ(0, result); |
| 34 USE(result); | 34 USE(result); |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 ConditionVariable::~ConditionVariable() { | 38 ConditionVariable::~ConditionVariable() { |
| 39 #if defined(V8_OS_MACOSX) |
| 40 // This hack is necessary to avoid a fatal pthreads subsystem bug in the |
| 41 // Darwin kernel. http://crbug.com/517681. |
| 42 { |
| 43 Mutex lock; |
| 44 LockGuard<Mutex> l(&lock); |
| 45 struct timespec ts; |
| 46 ts.tv_sec = 0; |
| 47 ts.tv_nsec = 1; |
| 48 pthread_cond_timedwait_relative_np(&native_handle_, &lock.native_handle(), |
| 49 &ts); |
| 50 } |
| 51 #endif |
| 39 int result = pthread_cond_destroy(&native_handle_); | 52 int result = pthread_cond_destroy(&native_handle_); |
| 40 DCHECK_EQ(0, result); | 53 DCHECK_EQ(0, result); |
| 41 USE(result); | 54 USE(result); |
| 42 } | 55 } |
| 43 | 56 |
| 44 | 57 |
| 45 void ConditionVariable::NotifyOne() { | 58 void ConditionVariable::NotifyOne() { |
| 46 int result = pthread_cond_signal(&native_handle_); | 59 int result = pthread_cond_signal(&native_handle_); |
| 47 DCHECK_EQ(0, result); | 60 DCHECK_EQ(0, result); |
| 48 USE(result); | 61 USE(result); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 DCHECK(!result || event->notified_); | 321 DCHECK(!result || event->notified_); |
| 309 native_handle_.Post(event, result); | 322 native_handle_.Post(event, result); |
| 310 | 323 |
| 311 return result; | 324 return result; |
| 312 } | 325 } |
| 313 | 326 |
| 314 #endif // V8_OS_POSIX | 327 #endif // V8_OS_POSIX |
| 315 | 328 |
| 316 } // namespace base | 329 } // namespace base |
| 317 } // namespace v8 | 330 } // namespace v8 |
| OLD | NEW |