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

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

Issue 995883002: Yesterday's deadlock fix was wrong. It could drop notifications. (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/observatory/lib/src/elements/debugger.dart ('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_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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 pool_ = pool; 87 pool_ = pool;
88 start_callback_ = start_callback; 88 start_callback_ = start_callback;
89 end_callback_ = end_callback; 89 end_callback_ = end_callback;
90 callback_data_ = data; 90 callback_data_ = data;
91 task_ = new MessageHandlerTask(this); 91 task_ = new MessageHandlerTask(this);
92 pool_->Run(task_); 92 pool_->Run(task_);
93 } 93 }
94 94
95 95
96 void MessageHandler::PostMessage(Message* message, bool before_events) { 96 void MessageHandler::PostMessage(Message* message, bool before_events) {
97 MonitorLocker ml(&monitor_); 97 Message::Priority saved_priority;
98 if (FLAG_trace_isolates) { 98 {
99 const char* source_name = "<native code>"; 99 MonitorLocker ml(&monitor_);
100 Isolate* source_isolate = Isolate::Current(); 100 if (FLAG_trace_isolates) {
101 if (source_isolate) { 101 const char* source_name = "<native code>";
102 source_name = source_isolate->name(); 102 Isolate* source_isolate = Isolate::Current();
103 if (source_isolate) {
104 source_name = source_isolate->name();
105 }
106 OS::Print("[>] Posting message:\n"
107 "\tlen: %" Pd "\n"
108 "\tsource: %s\n"
109 "\tdest: %s\n"
110 "\tdest_port: %" Pd64 "\n",
111 message->len(), source_name, name(), message->dest_port());
103 } 112 }
104 OS::Print("[>] Posting message:\n" 113
105 "\tlen: %" Pd "\n" 114 saved_priority = message->priority();
106 "\tsource: %s\n" 115 if (message->IsOOB()) {
107 "\tdest: %s\n" 116 oob_queue_->Enqueue(message, before_events);
108 "\tdest_port: %" Pd64 "\n", 117 } else {
109 message->len(), source_name, name(), message->dest_port()); 118 queue_->Enqueue(message, before_events);
119 }
120 message = NULL; // Do not access message. May have been deleted.
121
122 if (pool_ != NULL && task_ == NULL) {
123 task_ = new MessageHandlerTask(this);
124 pool_->Run(task_);
125 }
110 } 126 }
111
112 Message::Priority saved_priority = message->priority();
113 if (message->IsOOB()) {
114 oob_queue_->Enqueue(message, before_events);
115 } else {
116 queue_->Enqueue(message, before_events);
117 }
118 message = NULL; // Do not access message. May have been deleted.
119
120 if (pool_ != NULL && task_ == NULL) {
121 task_ = new MessageHandlerTask(this);
122 pool_->Run(task_);
123 }
124
125 // Invoke any custom message notification. 127 // Invoke any custom message notification.
126 MessageNotify(saved_priority); 128 MessageNotify(saved_priority);
127 } 129 }
128 130
129 131
130 Message* MessageHandler::DequeueMessage(Message::Priority min_priority) { 132 Message* MessageHandler::DequeueMessage(Message::Priority min_priority) {
131 // TODO(turnidge): Add assert that monitor_ is held here. 133 // TODO(turnidge): Add assert that monitor_ is held here.
132 Message* message = oob_queue_->Dequeue(); 134 Message* message = oob_queue_->Dequeue();
133 if ((message == NULL) && (min_priority < Message::kOOBPriority)) { 135 if ((message == NULL) && (min_priority < Message::kOOBPriority)) {
134 message = queue_->Dequeue(); 136 message = queue_->Dequeue();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 327
326 void MessageHandler::decrement_live_ports() { 328 void MessageHandler::decrement_live_ports() {
327 MonitorLocker ml(&monitor_); 329 MonitorLocker ml(&monitor_);
328 #if defined(DEBUG) 330 #if defined(DEBUG)
329 CheckAccess(); 331 CheckAccess();
330 #endif 332 #endif
331 live_ports_--; 333 live_ports_--;
332 } 334 }
333 335
334 } // namespace dart 336 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/debugger.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698