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

Unified Diff: runtime/vm/message.cc

Issue 749373002: - Implement Isolate.ping. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/message.cc
===================================================================
--- runtime/vm/message.cc (revision 42173)
+++ runtime/vm/message.cc (working copy)
@@ -31,7 +31,7 @@
}
-void MessageQueue::Enqueue(Message* msg) {
+void MessageQueue::Enqueue(Message* msg, bool before_events) {
// Make sure messages are not reused.
ASSERT(msg->next_ == NULL);
if (head_ == NULL) {
@@ -41,9 +41,34 @@
tail_ = msg;
} else {
ASSERT(tail_ != NULL);
- // Append at the tail.
- tail_->next_ = msg;
- tail_ = msg;
+ if (!before_events) {
+ // Append at the tail.
+ tail_->next_ = msg;
+ tail_ = msg;
+ } else {
+ ASSERT(msg->dest_port() == Message::kIllegalPort);
+ if (head_->dest_port() != Message::kIllegalPort) {
+ msg->next_ = head_;
+ head_ = msg;
+ } else {
+ Message* cur = head_;
+ while (cur->next_ != NULL) {
+ if (cur->next_->dest_port() != Message::kIllegalPort) {
+ // Splice in the new message at the break.
+ msg->next_ = cur->next_;
+ cur->next_ = msg;
+ return;
+ }
+ cur = cur->next_;
+ }
+ // All pending messages are isolate library control messages. Append at
+ // the tail.
+ ASSERT(tail_ == cur);
+ ASSERT(tail_->dest_port() == Message::kIllegalPort);
+ tail_->next_ = msg;
+ tail_ = msg;
+ }
+ }
}
}
« no previous file with comments | « runtime/vm/message.h ('k') | runtime/vm/message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698