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 #ifndef VM_MESSAGE_HANDLER_H_ | 5 #ifndef VM_MESSAGE_HANDLER_H_ |
6 #define VM_MESSAGE_HANDLER_H_ | 6 #define VM_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/message.h" | 9 #include "vm/message.h" |
10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 void set_pause_on_exit(bool pause_on_exit) { | 91 void set_pause_on_exit(bool pause_on_exit) { |
92 pause_on_exit_ = pause_on_exit; | 92 pause_on_exit_ = pause_on_exit; |
93 } | 93 } |
94 | 94 |
95 bool paused_on_exit() const { | 95 bool paused_on_exit() const { |
96 return paused_on_exit_; | 96 return paused_on_exit_; |
97 } | 97 } |
98 | 98 |
| 99 class AcquiredQueues : public ValueObject { |
| 100 public: |
| 101 AcquiredQueues(); |
| 102 |
| 103 ~AcquiredQueues(); |
| 104 |
| 105 MessageQueue* queue() { |
| 106 if (handler_ == NULL) { |
| 107 return NULL; |
| 108 } |
| 109 return handler_->queue_; |
| 110 } |
| 111 |
| 112 MessageQueue* oob_queue() { |
| 113 if (handler_ == NULL) { |
| 114 return NULL; |
| 115 } |
| 116 return handler_->oob_queue_; |
| 117 } |
| 118 |
| 119 private: |
| 120 void Reset(MessageHandler* handler); |
| 121 |
| 122 MessageHandler* handler_; |
| 123 |
| 124 friend class MessageHandler; |
| 125 }; |
| 126 |
| 127 // Gives temporary ownership of |queue| and |oob_queue|. Calling this |
| 128 // has the side effect that no OOB messages will be handled if a stack |
| 129 // overflow interrupt is delivered. |
| 130 void AcquireQueues(AcquiredQueues* acquired_queue); |
99 | 131 |
100 #if defined(DEBUG) | 132 #if defined(DEBUG) |
101 // Check that it is safe to access this message handler. | 133 // Check that it is safe to access this message handler. |
102 // | 134 // |
103 // For example, if this MessageHandler is an isolate, then it is | 135 // For example, if this MessageHandler is an isolate, then it is |
104 // only safe to access it when the MessageHandler is the current | 136 // only safe to access it when the MessageHandler is the current |
105 // isolate. | 137 // isolate. |
106 virtual void CheckAccess(); | 138 virtual void CheckAccess(); |
107 #endif | 139 #endif |
108 | 140 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // messages from the queue_. | 191 // messages from the queue_. |
160 Message* DequeueMessage(Message::Priority min_priority); | 192 Message* DequeueMessage(Message::Priority min_priority); |
161 | 193 |
162 // Handles any pending messages. | 194 // Handles any pending messages. |
163 bool HandleMessages(bool allow_normal_messages, | 195 bool HandleMessages(bool allow_normal_messages, |
164 bool allow_multiple_normal_messages); | 196 bool allow_multiple_normal_messages); |
165 | 197 |
166 Monitor monitor_; // Protects all fields in MessageHandler. | 198 Monitor monitor_; // Protects all fields in MessageHandler. |
167 MessageQueue* queue_; | 199 MessageQueue* queue_; |
168 MessageQueue* oob_queue_; | 200 MessageQueue* oob_queue_; |
| 201 // This flag is not thread safe and can only reliably be accessed on a single |
| 202 // thread. |
| 203 bool oob_message_handling_allowed_; |
169 intptr_t live_ports_; // The number of open ports, including control ports. | 204 intptr_t live_ports_; // The number of open ports, including control ports. |
170 intptr_t paused_; // The number of pause messages received. | 205 intptr_t paused_; // The number of pause messages received. |
171 bool pause_on_start_; | 206 bool pause_on_start_; |
172 bool pause_on_exit_; | 207 bool pause_on_exit_; |
173 bool paused_on_start_; | 208 bool paused_on_start_; |
174 bool paused_on_exit_; | 209 bool paused_on_exit_; |
175 ThreadPool* pool_; | 210 ThreadPool* pool_; |
176 ThreadPool::Task* task_; | 211 ThreadPool::Task* task_; |
177 StartCallback start_callback_; | 212 StartCallback start_callback_; |
178 EndCallback end_callback_; | 213 EndCallback end_callback_; |
179 CallbackData callback_data_; | 214 CallbackData callback_data_; |
180 | 215 |
181 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 216 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
182 }; | 217 }; |
183 | 218 |
184 } // namespace dart | 219 } // namespace dart |
185 | 220 |
186 #endif // VM_MESSAGE_HANDLER_H_ | 221 #endif // VM_MESSAGE_HANDLER_H_ |
OLD | NEW |