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

Unified Diff: runtime/vm/message_handler.cc

Issue 354763004: - Implement Isolate.pause and Isolate.resume. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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
Index: runtime/vm/message_handler.cc
===================================================================
--- runtime/vm/message_handler.cc (revision 37860)
+++ runtime/vm/message_handler.cc (working copy)
@@ -34,6 +34,7 @@
oob_queue_(new MessageQueue()),
control_ports_(0),
live_ports_(0),
+ paused_(0),
pause_on_start_(false),
pause_on_exit_(false),
paused_on_exit_(false),
@@ -126,7 +127,7 @@
Message* MessageHandler::DequeueMessage(Message::Priority min_priority) {
// TODO(turnidge): Add assert that monitor_ is held here.
Message* message = oob_queue_->Dequeue();
- if (message == NULL && min_priority < Message::kOOBPriority) {
+ if ((message == NULL) && (min_priority < Message::kOOBPriority)) {
message = queue_->Dequeue();
}
return message;
@@ -137,9 +138,8 @@
bool allow_multiple_normal_messages) {
// TODO(turnidge): Add assert that monitor_ is held here.
bool result = true;
- Message::Priority min_priority = (allow_normal_messages
- ? Message::kNormalPriority
- : Message::kOOBPriority);
+ Message::Priority min_priority = (allow_normal_messages && !paused()) ?
+ Message::kNormalPriority : Message::kOOBPriority;
Message* message = DequeueMessage(min_priority);
while (message != NULL) {
if (FLAG_trace_isolates) {
@@ -165,11 +165,17 @@
// If we hit an error, we're done processing messages.
break;
}
- if (!allow_multiple_normal_messages &&
- saved_priority == Message::kNormalPriority) {
- // Some callers want to process only one normal message and then quit.
+ // Some callers want to process only one normal message and then quit. At
+ // the same time it is OK to process multiple OOB messages.
+ if ((saved_priority == Message::kNormalPriority) &&
+ !allow_multiple_normal_messages) {
break;
}
+
+ // Reevaluate the minimum allowable priority as the paused state might
+ // have changed as part of handling the message.
+ min_priority = (allow_normal_messages && !paused()) ?
+ Message::kNormalPriority : Message::kOOBPriority;
message = DequeueMessage(min_priority);
}
return result;
@@ -216,6 +222,8 @@
}
if (start_callback_) {
+ // Release the monitor_ temporarily while we call the start callback.
+ // The monitor was acquired with the MonitorLocker above.
monitor_.Exit();
ok = start_callback_(callback_data_);
ASSERT(Isolate::Current() == NULL);

Powered by Google App Engine
This is Rietveld 408576698