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

Side by Side Diff: runtime/vm/message_queue.cc

Issue 8392044: Handle spurious wakeups properly. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/message_queue.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/message_queue.h" 5 #include "vm/message_queue.h"
6 6
7 namespace dart { 7 namespace dart {
8 8
9 MessageQueue::~MessageQueue() { 9 MessageQueue::~MessageQueue() {
10 // Ensure that all pending messages have been released. 10 // Ensure that all pending messages have been released.
(...skipping 20 matching lines...) Expand all
31 // Append at the tail. 31 // Append at the tail.
32 tail_->next_ = msg; 32 tail_->next_ = msg;
33 tail_ = msg; 33 tail_ = msg;
34 } 34 }
35 35
36 monitor_.Exit(); 36 monitor_.Exit();
37 } 37 }
38 38
39 39
40 PortMessage* MessageQueue::Dequeue(int64_t millis) { 40 PortMessage* MessageQueue::Dequeue(int64_t millis) {
41 ASSERT(millis >= 0);
41 MonitorLocker ml(&monitor_); 42 MonitorLocker ml(&monitor_);
42 PortMessage* result = head_; 43 PortMessage* result = head_;
43 if (result == NULL) { 44 if (result == NULL) {
44 ml.Wait(millis); 45 ml.Wait(millis);
45 result = head_; 46 result = head_;
46 } 47 }
47 if (result != NULL) { 48 if (result != NULL) {
48 head_ = result->next_; 49 head_ = result->next_;
49 // The following update to tail_ is not strictly needed. 50 // The following update to tail_ is not strictly needed.
50 if (head_ == NULL) { 51 if (head_ == NULL) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 tail_ = NULL; 91 tail_ = NULL;
91 while (cur != NULL) { 92 while (cur != NULL) {
92 PortMessage* next = cur->next_; 93 PortMessage* next = cur->next_;
93 delete cur; 94 delete cur;
94 cur = next; 95 cur = next;
95 } 96 }
96 } 97 }
97 98
98 99
99 } // namespace dart 100 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/message_queue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698