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/message.h" | 8 #include "vm/message.h" |
9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
10 #include "vm/thread_pool.h" | 10 #include "vm/thread_pool.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // The number of opened control ports is determined whether the isolate has | 56 // The number of opened control ports is determined whether the isolate has |
57 // live ports. An isolate is considered not having any live ports if only | 57 // live ports. An isolate is considered not having any live ports if only |
58 // control ports are open. | 58 // control ports are open. |
59 // Usually either 0 or 1. | 59 // Usually either 0 or 1. |
60 void increment_control_ports(); | 60 void increment_control_ports(); |
61 void decrement_control_ports(); | 61 void decrement_control_ports(); |
62 | 62 |
63 // A message handler tracks how many live ports it has. | 63 // A message handler tracks how many live ports it has. |
64 bool HasLivePorts() const { return live_ports_ > control_ports_; } | 64 bool HasLivePorts() const { return live_ports_ > control_ports_; } |
65 | 65 |
| 66 intptr_t live_ports() const { |
| 67 return live_ports_; |
| 68 } |
| 69 |
| 70 intptr_t control_ports() const { |
| 71 return control_ports_; |
| 72 } |
| 73 |
| 74 bool pause_on_start() const { |
| 75 return pause_on_start_; |
| 76 } |
| 77 |
| 78 void set_pause_on_start(bool pause_on_start) { |
| 79 pause_on_start_ = pause_on_start; |
| 80 } |
| 81 |
| 82 bool pause_on_exit() const { |
| 83 return pause_on_exit_; |
| 84 } |
| 85 |
| 86 void set_pause_on_exit(bool pause_on_exit) { |
| 87 pause_on_exit_ = pause_on_exit; |
| 88 } |
| 89 |
| 90 bool paused_on_exit() const { |
| 91 return paused_on_exit_; |
| 92 } |
| 93 |
| 94 |
66 #if defined(DEBUG) | 95 #if defined(DEBUG) |
67 // Check that it is safe to access this message handler. | 96 // Check that it is safe to access this message handler. |
68 // | 97 // |
69 // For example, if this MessageHandler is an isolate, then it is | 98 // For example, if this MessageHandler is an isolate, then it is |
70 // only safe to access it when the MessageHandler is the current | 99 // only safe to access it when the MessageHandler is the current |
71 // isolate. | 100 // isolate. |
72 virtual void CheckAccess(); | 101 virtual void CheckAccess(); |
73 #endif | 102 #endif |
74 | 103 |
75 protected: | 104 protected: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 151 |
123 // Handles any pending messages. | 152 // Handles any pending messages. |
124 bool HandleMessages(bool allow_normal_messages, | 153 bool HandleMessages(bool allow_normal_messages, |
125 bool allow_multiple_normal_messages); | 154 bool allow_multiple_normal_messages); |
126 | 155 |
127 Monitor monitor_; // Protects all fields in MessageHandler. | 156 Monitor monitor_; // Protects all fields in MessageHandler. |
128 MessageQueue* queue_; | 157 MessageQueue* queue_; |
129 MessageQueue* oob_queue_; | 158 MessageQueue* oob_queue_; |
130 intptr_t control_ports_; // The number of open control ports usually 0 or 1. | 159 intptr_t control_ports_; // The number of open control ports usually 0 or 1. |
131 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. |
| 161 bool pause_on_start_; |
| 162 bool pause_on_exit_; |
| 163 bool paused_on_exit_; |
132 ThreadPool* pool_; | 164 ThreadPool* pool_; |
133 ThreadPool::Task* task_; | 165 ThreadPool::Task* task_; |
134 StartCallback start_callback_; | 166 StartCallback start_callback_; |
135 EndCallback end_callback_; | 167 EndCallback end_callback_; |
136 CallbackData callback_data_; | 168 CallbackData callback_data_; |
137 | 169 |
138 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 170 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
139 }; | 171 }; |
140 | 172 |
141 } // namespace dart | 173 } // namespace dart |
142 | 174 |
143 #endif // VM_MESSAGE_HANDLER_H_ | 175 #endif // VM_MESSAGE_HANDLER_H_ |
OLD | NEW |