Chromium Code Reviews| Index: runtime/vm/message_queue.cc |
| diff --git a/runtime/vm/message_queue.cc b/runtime/vm/message_queue.cc |
| index 2f67a2153141ab93978c8373030ee6c24fedeb84..a4b7b6ae37bcb64192d0fe8234ed4ac31206cdcf 100644 |
| --- a/runtime/vm/message_queue.cc |
| +++ b/runtime/vm/message_queue.cc |
| @@ -40,9 +40,13 @@ void MessageQueue::Enqueue(PortMessage* msg) { |
| PortMessage* MessageQueue::Dequeue(int64_t millis) { |
| MonitorLocker ml(&monitor_); |
| PortMessage* result = head_; |
| - if (result == NULL) { |
| + // Wait may wake up prematurely, so we need to loop until result != NULL |
|
siva
2011/10/21 21:18:33
// Wait for message to be enqueued or timeout.
|
| + while (result == NULL) { |
| ml.Wait(millis); |
| result = head_; |
| + // If there's a time-out the caller must check for NULL anyway. |
| + if (0 < millis) |
| + break; |
|
siva
2011/10/21 21:18:33
This is not correct, if a spurious wake up happens
jrgfogh
2011/10/24 09:20:42
I know. Neither way is strictly correct. My code h
|
| } |
| if (result != NULL) { |
| head_ = result->next_; |