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.h" | 5 #include "vm/message.h" |
6 | 6 |
| 7 #include "vm/port.h" |
| 8 |
7 namespace dart { | 9 namespace dart { |
8 | 10 |
| 11 bool Message::RedirectToDeliveryFailurePort() { |
| 12 if (delivery_failure_port_ == kIllegalPort) { |
| 13 return false; |
| 14 } |
| 15 dest_port_ = delivery_failure_port_; |
| 16 delivery_failure_port_ = kIllegalPort; |
| 17 return true; |
| 18 } |
| 19 |
| 20 |
9 MessageQueue::MessageQueue() { | 21 MessageQueue::MessageQueue() { |
10 head_ = NULL; | 22 head_ = NULL; |
11 tail_ = NULL; | 23 tail_ = NULL; |
12 } | 24 } |
13 | 25 |
14 | 26 |
15 MessageQueue::~MessageQueue() { | 27 MessageQueue::~MessageQueue() { |
16 // Ensure that all pending messages have been released. | 28 // Ensure that all pending messages have been released. |
17 Clear(); | 29 Clear(); |
18 ASSERT(head_ == NULL); | 30 ASSERT(head_ == NULL); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return NULL; | 64 return NULL; |
53 } | 65 } |
54 | 66 |
55 | 67 |
56 void MessageQueue::Clear() { | 68 void MessageQueue::Clear() { |
57 Message* cur = head_; | 69 Message* cur = head_; |
58 head_ = NULL; | 70 head_ = NULL; |
59 tail_ = NULL; | 71 tail_ = NULL; |
60 while (cur != NULL) { | 72 while (cur != NULL) { |
61 Message* next = cur->next_; | 73 Message* next = cur->next_; |
62 delete cur; | 74 if (cur->RedirectToDeliveryFailurePort()) { |
| 75 PortMap::PostMessage(cur); |
| 76 } else { |
| 77 delete cur; |
| 78 } |
63 cur = next; | 79 cur = next; |
64 } | 80 } |
65 } | 81 } |
66 | 82 |
67 | 83 |
68 } // namespace dart | 84 } // namespace dart |
OLD | NEW |