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/thread.h" | 10 #include "vm/thread.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // | 47 // |
48 // Returns true on success. | 48 // Returns true on success. |
49 bool HandleNextMessage(); | 49 bool HandleNextMessage(); |
50 | 50 |
51 // Handles any OOB messages for this message handler. Can be used | 51 // Handles any OOB messages for this message handler. Can be used |
52 // even if the message handler is running on the thread pool. | 52 // even if the message handler is running on the thread pool. |
53 // | 53 // |
54 // Returns true on success. | 54 // Returns true on success. |
55 bool HandleOOBMessages(); | 55 bool HandleOOBMessages(); |
56 | 56 |
57 // The number of opened control ports is determined whether the isolate has | |
58 // live ports. An isolate is considered not having any live ports if only | |
59 // control ports are open. | |
60 // Usually either 0 or 1. | |
61 void increment_control_ports(); | |
62 void decrement_control_ports(); | |
63 | |
64 // A message handler tracks how many live ports it has. | 57 // A message handler tracks how many live ports it has. |
65 bool HasLivePorts() const { return live_ports_ > control_ports_; } | 58 bool HasLivePorts() const { return live_ports_ > 0; } |
66 | 59 |
67 intptr_t live_ports() const { | 60 intptr_t live_ports() const { |
68 return live_ports_; | 61 return live_ports_; |
69 } | 62 } |
70 | 63 |
71 intptr_t control_ports() const { | |
72 return control_ports_; | |
73 } | |
74 | |
75 bool paused() const { return paused_ > 0; } | 64 bool paused() const { return paused_ > 0; } |
76 | 65 |
77 void increment_paused() { paused_++; } | 66 void increment_paused() { paused_++; } |
78 void decrement_paused() { ASSERT(paused_ > 0); paused_--; } | 67 void decrement_paused() { ASSERT(paused_ > 0); paused_--; } |
79 | 68 |
80 bool pause_on_start() const { | 69 bool pause_on_start() const { |
81 return pause_on_start_; | 70 return pause_on_start_; |
82 } | 71 } |
83 | 72 |
84 void set_pause_on_start(bool pause_on_start) { | 73 void set_pause_on_start(bool pause_on_start) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // messages from the queue_. | 150 // messages from the queue_. |
162 Message* DequeueMessage(Message::Priority min_priority); | 151 Message* DequeueMessage(Message::Priority min_priority); |
163 | 152 |
164 // Handles any pending messages. | 153 // Handles any pending messages. |
165 bool HandleMessages(bool allow_normal_messages, | 154 bool HandleMessages(bool allow_normal_messages, |
166 bool allow_multiple_normal_messages); | 155 bool allow_multiple_normal_messages); |
167 | 156 |
168 Monitor monitor_; // Protects all fields in MessageHandler. | 157 Monitor monitor_; // Protects all fields in MessageHandler. |
169 MessageQueue* queue_; | 158 MessageQueue* queue_; |
170 MessageQueue* oob_queue_; | 159 MessageQueue* oob_queue_; |
171 intptr_t control_ports_; // The number of open control ports usually 0 or 1. | |
172 intptr_t live_ports_; // The number of open ports, including control ports. | 160 intptr_t live_ports_; // The number of open ports, including control ports. |
173 intptr_t paused_; // The number of pause messages received. | 161 intptr_t paused_; // The number of pause messages received. |
174 bool pause_on_start_; | 162 bool pause_on_start_; |
175 bool pause_on_exit_; | 163 bool pause_on_exit_; |
176 bool paused_on_exit_; | 164 bool paused_on_exit_; |
177 ThreadPool* pool_; | 165 ThreadPool* pool_; |
178 ThreadPool::Task* task_; | 166 ThreadPool::Task* task_; |
179 StartCallback start_callback_; | 167 StartCallback start_callback_; |
180 EndCallback end_callback_; | 168 EndCallback end_callback_; |
181 CallbackData callback_data_; | 169 CallbackData callback_data_; |
182 | 170 |
183 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 171 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
184 }; | 172 }; |
185 | 173 |
186 } // namespace dart | 174 } // namespace dart |
187 | 175 |
188 #endif // VM_MESSAGE_HANDLER_H_ | 176 #endif // VM_MESSAGE_HANDLER_H_ |
OLD | NEW |