OLD | NEW |
---|---|
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 16 matching lines...) Expand all Loading... | |
27 private: | 27 private: |
28 MessageHandler* handler_; | 28 MessageHandler* handler_; |
29 | 29 |
30 DISALLOW_COPY_AND_ASSIGN(MessageHandlerTask); | 30 DISALLOW_COPY_AND_ASSIGN(MessageHandlerTask); |
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 oob_message_handling_allowed_(true), | |
37 live_ports_(0), | 38 live_ports_(0), |
38 paused_(0), | 39 paused_(0), |
39 pause_on_start_(false), | 40 pause_on_start_(false), |
40 pause_on_exit_(false), | 41 pause_on_exit_(false), |
41 paused_on_start_(false), | 42 paused_on_start_(false), |
42 paused_on_exit_(false), | 43 paused_on_exit_(false), |
43 pool_(NULL), | 44 pool_(NULL), |
44 task_(NULL), | 45 task_(NULL), |
45 start_callback_(NULL), | 46 start_callback_(NULL), |
46 end_callback_(NULL), | 47 end_callback_(NULL), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 MonitorLocker ml(&monitor_); | 202 MonitorLocker ml(&monitor_); |
202 ASSERT(pool_ == NULL); | 203 ASSERT(pool_ == NULL); |
203 #if defined(DEBUG) | 204 #if defined(DEBUG) |
204 CheckAccess(); | 205 CheckAccess(); |
205 #endif | 206 #endif |
206 return HandleMessages(true, false); | 207 return HandleMessages(true, false); |
207 } | 208 } |
208 | 209 |
209 | 210 |
210 bool MessageHandler::HandleOOBMessages() { | 211 bool MessageHandler::HandleOOBMessages() { |
212 if (!oob_message_handling_allowed_) { | |
213 return true; | |
214 } | |
211 MonitorLocker ml(&monitor_); | 215 MonitorLocker ml(&monitor_); |
212 #if defined(DEBUG) | 216 #if defined(DEBUG) |
213 CheckAccess(); | 217 CheckAccess(); |
214 #endif | 218 #endif |
215 return HandleMessages(false, false); | 219 return HandleMessages(false, false); |
216 } | 220 } |
217 | 221 |
218 | 222 |
219 bool MessageHandler::HasOOBMessages() { | 223 bool MessageHandler::HasOOBMessages() { |
220 MonitorLocker ml(&monitor_); | 224 MonitorLocker ml(&monitor_); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 | 330 |
327 | 331 |
328 void MessageHandler::decrement_live_ports() { | 332 void MessageHandler::decrement_live_ports() { |
329 MonitorLocker ml(&monitor_); | 333 MonitorLocker ml(&monitor_); |
330 #if defined(DEBUG) | 334 #if defined(DEBUG) |
331 CheckAccess(); | 335 CheckAccess(); |
332 #endif | 336 #endif |
333 live_ports_--; | 337 live_ports_--; |
334 } | 338 } |
335 | 339 |
340 | |
341 MessageHandler::AcquiredQueues::AcquiredQueues() | |
342 : handler_(NULL) { | |
343 } | |
344 | |
345 | |
346 MessageHandler::AcquiredQueues::~AcquiredQueues() { | |
347 if (handler_ != NULL) { | |
348 // Release ownership. | |
349 handler_->oob_message_handling_allowed_ = true; | |
350 handler_->monitor_.Exit(); | |
351 } | |
turnidge
2015/05/04 17:47:13
Move the bulk of this into Reset.
Cutch
2015/05/04 19:56:51
Done.
| |
352 Reset(NULL); | |
353 } | |
354 | |
355 | |
356 void MessageHandler::AcquiredQueues::Reset(MessageHandler* handler) { | |
357 handler_ = handler; | |
358 if (handler_ == NULL) { | |
359 return; | |
360 } | |
361 ASSERT(handler_ != NULL); | |
362 // Take ownership. | |
363 handler_->monitor_.Enter(); | |
364 handler_->oob_message_handling_allowed_ = false; | |
turnidge
2015/05/04 17:47:13
Does this need to be done under the monitor here?
Cutch
2015/05/04 19:56:51
Done.
| |
365 } | |
366 | |
367 | |
368 void MessageHandler::AcquireQueues(AcquiredQueues* acquired_queues) { | |
369 ASSERT(acquired_queues != NULL); | |
370 // No double dipping. | |
371 ASSERT(acquired_queues->handler_ == NULL); | |
372 acquired_queues->Reset(this); | |
373 } | |
374 | |
336 } // namespace dart | 375 } // namespace dart |
OLD | NEW |