| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return pause_on_start_; | 74 return pause_on_start_; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void set_pause_on_start(bool pause_on_start) { | 77 void set_pause_on_start(bool pause_on_start) { |
| 78 pause_on_start_ = pause_on_start; | 78 pause_on_start_ = pause_on_start; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool paused_on_start() const { | 81 bool paused_on_start() const { |
| 82 // If pause_on_start_ is still set, tell the user we are paused, | 82 // If pause_on_start_ is still set, tell the user we are paused, |
| 83 // even if we haven't hit the pause point yet. | 83 // even if we haven't hit the pause point yet. |
| 84 return pause_on_start_; | 84 return paused_on_start_; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool pause_on_exit() const { | 87 bool pause_on_exit() const { |
| 88 return pause_on_exit_; | 88 return pause_on_exit_; |
| 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // ------------ END PortMap API ------------ | 137 // ------------ END PortMap API ------------ |
| 138 | 138 |
| 139 // Custom message notification. Optionally provided by subclass. | 139 // Custom message notification. Optionally provided by subclass. |
| 140 virtual void MessageNotify(Message::Priority priority); | 140 virtual void MessageNotify(Message::Priority priority); |
| 141 | 141 |
| 142 // Handles a single message. Provided by subclass. | 142 // Handles a single message. Provided by subclass. |
| 143 // | 143 // |
| 144 // Returns true on success. | 144 // Returns true on success. |
| 145 virtual bool HandleMessage(Message* message) = 0; | 145 virtual bool HandleMessage(Message* message) = 0; |
| 146 | 146 |
| 147 virtual void NotifyPauseOnStart() {} |
| 148 virtual void NotifyPauseOnExit() {} |
| 149 |
| 147 private: | 150 private: |
| 148 friend class PortMap; | 151 friend class PortMap; |
| 149 friend class MessageHandlerTestPeer; | 152 friend class MessageHandlerTestPeer; |
| 150 friend class MessageHandlerTask; | 153 friend class MessageHandlerTask; |
| 151 | 154 |
| 152 // Called by MessageHandlerTask to process our task queue. | 155 // Called by MessageHandlerTask to process our task queue. |
| 153 void TaskCallback(); | 156 void TaskCallback(); |
| 154 | 157 |
| 155 // Dequeue the next message. Prefer messages from the oob_queue_ to | 158 // Dequeue the next message. Prefer messages from the oob_queue_ to |
| 156 // messages from the queue_. | 159 // messages from the queue_. |
| 157 Message* DequeueMessage(Message::Priority min_priority); | 160 Message* DequeueMessage(Message::Priority min_priority); |
| 158 | 161 |
| 159 // Handles any pending messages. | 162 // Handles any pending messages. |
| 160 bool HandleMessages(bool allow_normal_messages, | 163 bool HandleMessages(bool allow_normal_messages, |
| 161 bool allow_multiple_normal_messages); | 164 bool allow_multiple_normal_messages); |
| 162 | 165 |
| 163 Monitor monitor_; // Protects all fields in MessageHandler. | 166 Monitor monitor_; // Protects all fields in MessageHandler. |
| 164 MessageQueue* queue_; | 167 MessageQueue* queue_; |
| 165 MessageQueue* oob_queue_; | 168 MessageQueue* oob_queue_; |
| 166 intptr_t live_ports_; // The number of open ports, including control ports. | 169 intptr_t live_ports_; // The number of open ports, including control ports. |
| 167 intptr_t paused_; // The number of pause messages received. | 170 intptr_t paused_; // The number of pause messages received. |
| 168 bool pause_on_start_; | 171 bool pause_on_start_; |
| 169 bool pause_on_exit_; | 172 bool pause_on_exit_; |
| 173 bool paused_on_start_; |
| 170 bool paused_on_exit_; | 174 bool paused_on_exit_; |
| 171 ThreadPool* pool_; | 175 ThreadPool* pool_; |
| 172 ThreadPool::Task* task_; | 176 ThreadPool::Task* task_; |
| 173 StartCallback start_callback_; | 177 StartCallback start_callback_; |
| 174 EndCallback end_callback_; | 178 EndCallback end_callback_; |
| 175 CallbackData callback_data_; | 179 CallbackData callback_data_; |
| 176 | 180 |
| 177 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 181 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
| 178 }; | 182 }; |
| 179 | 183 |
| 180 } // namespace dart | 184 } // namespace dart |
| 181 | 185 |
| 182 #endif // VM_MESSAGE_HANDLER_H_ | 186 #endif // VM_MESSAGE_HANDLER_H_ |
| OLD | NEW |