Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Unified Diff: runtime/vm/message_queue.cc

Issue 8362026: Fixed a problem with spurious wakeups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/thread.h » ('j') | runtime/vm/thread.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | runtime/vm/thread.h » ('j') | runtime/vm/thread.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698