| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(HOST_OS_FUCHSIA) | 6 #if defined(HOST_OS_FUCHSIA) |
| 7 | 7 |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 #include "bin/thread_fuchsia.h" | 9 #include "bin/thread_fuchsia.h" |
| 10 | 10 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 Monitor::WaitResult Monitor::Wait(int64_t millis) { | 283 Monitor::WaitResult Monitor::Wait(int64_t millis) { |
| 284 return WaitMicros(millis * kMicrosecondsPerMillisecond); | 284 return WaitMicros(millis * kMicrosecondsPerMillisecond); |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { | 288 Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { |
| 289 // TODO(iposva): Do we need to track lock owners? | 289 // TODO(iposva): Do we need to track lock owners? |
| 290 Monitor::WaitResult retval = kNotified; | 290 Monitor::WaitResult retval = kNotified; |
| 291 if (micros == kNoTimeout) { | 291 if (micros == kNoTimeout) { |
| 292 // Wait forever. | 292 // Wait forever. |
| 293 int result = pthread_cond_wait(data_.cond(), data_.mutex()); | 293 int result; |
| 294 do { |
| 295 result = pthread_cond_wait(data_.cond(), data_.mutex()); |
| 296 // TODO(MG-795): Disallow ETIMEDOUT when pthread_cond_wait() can no longer |
| 297 // return it. |
| 298 } while (result == ETIMEDOUT); |
| 294 VALIDATE_PTHREAD_RESULT(result); | 299 VALIDATE_PTHREAD_RESULT(result); |
| 295 } else { | 300 } else { |
| 296 struct timespec ts; | 301 struct timespec ts; |
| 297 ComputeTimeSpecMicros(&ts, micros); | 302 ComputeTimeSpecMicros(&ts, micros); |
| 298 int result = pthread_cond_timedwait(data_.cond(), data_.mutex(), &ts); | 303 int result = pthread_cond_timedwait(data_.cond(), data_.mutex(), &ts); |
| 299 ASSERT((result == 0) || (result == ETIMEDOUT)); | 304 ASSERT((result == 0) || (result == ETIMEDOUT)); |
| 300 if (result == ETIMEDOUT) { | 305 if (result == ETIMEDOUT) { |
| 301 retval = kTimedOut; | 306 retval = kTimedOut; |
| 302 } | 307 } |
| 303 } | 308 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 315 void Monitor::NotifyAll() { | 320 void Monitor::NotifyAll() { |
| 316 // TODO(iposva): Do we need to track lock owners? | 321 // TODO(iposva): Do we need to track lock owners? |
| 317 int result = pthread_cond_broadcast(data_.cond()); | 322 int result = pthread_cond_broadcast(data_.cond()); |
| 318 VALIDATE_PTHREAD_RESULT(result); | 323 VALIDATE_PTHREAD_RESULT(result); |
| 319 } | 324 } |
| 320 | 325 |
| 321 } // namespace bin | 326 } // namespace bin |
| 322 } // namespace dart | 327 } // namespace dart |
| 323 | 328 |
| 324 #endif // defined(HOST_OS_FUCHSIA) | 329 #endif // defined(HOST_OS_FUCHSIA) |
| OLD | NEW |