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

Unified Diff: runtime/vm/message.cc

Issue 11642048: Revert "Optimize the message queue for many active ports with few messages." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « runtime/vm/message.h ('k') | runtime/vm/message_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/message.cc
diff --git a/runtime/vm/message.cc b/runtime/vm/message.cc
index 73f5da3c76b62652c2ee2c1b52285831e59524c6..807de7ea9ec7101b96619d33fd7c1ae632f68257 100644
--- a/runtime/vm/message.cc
+++ b/runtime/vm/message.cc
@@ -14,8 +14,9 @@ MessageQueue::MessageQueue() {
MessageQueue::~MessageQueue() {
// Ensure that all pending messages have been released.
- Clear();
+#if defined(DEBUG)
ASSERT(head_ == NULL);
+#endif
}
@@ -53,7 +54,31 @@ Message* MessageQueue::Dequeue() {
}
-void MessageQueue::Clear() {
+void MessageQueue::Flush(Dart_Port port) {
+ Message* cur = head_;
+ Message* prev = NULL;
+ while (cur != NULL) {
+ Message* next = cur->next_;
+ // If the message matches, then remove it from the queue and delete it.
+ if (cur->dest_port() == port) {
+ if (prev != NULL) {
+ prev->next_ = next;
+ } else {
+ head_ = next;
+ }
+ delete cur;
+ } else {
+ // Move prev forward.
+ prev = cur;
+ }
+ // Advance to the next message in the queue.
+ cur = next;
+ }
+ tail_ = prev;
+}
+
+
+void MessageQueue::FlushAll() {
Message* cur = head_;
head_ = NULL;
tail_ = NULL;
« no previous file with comments | « runtime/vm/message.h ('k') | runtime/vm/message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698