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

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

Issue 979823003: Major rework of vm service events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/message_handler.h ('k') | runtime/vm/service.h » ('j') | 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_handler.h" 5 #include "vm/message_handler.h"
6 6
7 #include "vm/dart.h" 7 #include "vm/dart.h"
8 #include "vm/lockers.h" 8 #include "vm/lockers.h"
9 #include "vm/port.h" 9 #include "vm/port.h"
10 10
(...skipping 20 matching lines...) Expand all
31 }; 31 };
32 32
33 33
34 MessageHandler::MessageHandler() 34 MessageHandler::MessageHandler()
35 : queue_(new MessageQueue()), 35 : queue_(new MessageQueue()),
36 oob_queue_(new MessageQueue()), 36 oob_queue_(new MessageQueue()),
37 live_ports_(0), 37 live_ports_(0),
38 paused_(0), 38 paused_(0),
39 pause_on_start_(false), 39 pause_on_start_(false),
40 pause_on_exit_(false), 40 pause_on_exit_(false),
41 paused_on_start_(false),
41 paused_on_exit_(false), 42 paused_on_exit_(false),
42 pool_(NULL), 43 pool_(NULL),
43 task_(NULL), 44 task_(NULL),
44 start_callback_(NULL), 45 start_callback_(NULL),
45 end_callback_(NULL), 46 end_callback_(NULL),
46 callback_data_(0) { 47 callback_data_(0) {
47 ASSERT(queue_ != NULL); 48 ASSERT(queue_ != NULL);
48 ASSERT(oob_queue_ != NULL); 49 ASSERT(oob_queue_ != NULL);
49 } 50 }
50 51
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void MessageHandler::TaskCallback() { 219 void MessageHandler::TaskCallback() {
219 ASSERT(Isolate::Current() == NULL); 220 ASSERT(Isolate::Current() == NULL);
220 bool ok = true; 221 bool ok = true;
221 bool run_end_callback = false; 222 bool run_end_callback = false;
222 { 223 {
223 MonitorLocker ml(&monitor_); 224 MonitorLocker ml(&monitor_);
224 // Initialize the message handler by running its start function, 225 // Initialize the message handler by running its start function,
225 // if we have one. For an isolate, this will run the isolate's 226 // if we have one. For an isolate, this will run the isolate's
226 // main() function. 227 // main() function.
227 if (pause_on_start()) { 228 if (pause_on_start()) {
229 if (!paused_on_start_) {
230 NotifyPauseOnStart();
231 paused_on_start_ = true;
232 }
228 HandleMessages(false, false); 233 HandleMessages(false, false);
229 if (pause_on_start()) { 234 if (pause_on_start()) {
230 // Still paused. 235 // Still paused.
231 task_ = NULL; // No task in queue. 236 task_ = NULL; // No task in queue.
232 return; 237 return;
238 } else {
239 paused_on_start_ = false;
233 } 240 }
234 } 241 }
235 242
236 if (start_callback_) { 243 if (start_callback_) {
237 // Release the monitor_ temporarily while we call the start callback. 244 // Release the monitor_ temporarily while we call the start callback.
238 // The monitor was acquired with the MonitorLocker above. 245 // The monitor was acquired with the MonitorLocker above.
239 monitor_.Exit(); 246 monitor_.Exit();
240 ok = start_callback_(callback_data_); 247 ok = start_callback_(callback_data_);
241 ASSERT(Isolate::Current() == NULL); 248 ASSERT(Isolate::Current() == NULL);
242 start_callback_ = NULL; 249 start_callback_ = NULL;
243 monitor_.Enter(); 250 monitor_.Enter();
244 } 251 }
245 252
246 // Handle any pending messages for this message handler. 253 // Handle any pending messages for this message handler.
247 if (ok) { 254 if (ok) {
248 ok = HandleMessages(true, true); 255 ok = HandleMessages(true, true);
249 } 256 }
250 task_ = NULL; // No task in queue. 257 task_ = NULL; // No task in queue.
251 258
252 if (!ok || !HasLivePorts()) { 259 if (!ok || !HasLivePorts()) {
253 if (pause_on_exit()) { 260 if (pause_on_exit()) {
254 if (FLAG_trace_service_pause_events && !paused_on_exit_) { 261 if (!paused_on_exit_) {
255 OS::PrintErr("Isolate %s paused before exiting. " 262 if (FLAG_trace_service_pause_events) {
263 OS::PrintErr("Isolate %s paused before exiting. "
256 "Use the Observatory to release it.\n", name()); 264 "Use the Observatory to release it.\n", name());
265 }
266 NotifyPauseOnExit();
267 paused_on_exit_ = true;
257 } 268 }
258 paused_on_exit_ = true;
259 } else { 269 } else {
260 if (FLAG_trace_isolates) { 270 if (FLAG_trace_isolates) {
261 OS::Print("[-] Stopping message handler (%s):\n" 271 OS::Print("[-] Stopping message handler (%s):\n"
262 "\thandler: %s\n", 272 "\thandler: %s\n",
263 (ok ? "no live ports" : "error"), 273 (ok ? "no live ports" : "error"),
264 name()); 274 name());
265 } 275 }
266 pool_ = NULL; 276 pool_ = NULL;
267 run_end_callback = true; 277 run_end_callback = true;
268 paused_on_exit_ = false; 278 paused_on_exit_ = false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 321
312 void MessageHandler::decrement_live_ports() { 322 void MessageHandler::decrement_live_ports() {
313 MonitorLocker ml(&monitor_); 323 MonitorLocker ml(&monitor_);
314 #if defined(DEBUG) 324 #if defined(DEBUG)
315 CheckAccess(); 325 CheckAccess();
316 #endif 326 #endif
317 live_ports_--; 327 live_ports_--;
318 } 328 }
319 329
320 } // namespace dart 330 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/message_handler.h ('k') | runtime/vm/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698