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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 EndCallback end_callback, | 49 EndCallback end_callback, |
50 CallbackData data); | 50 CallbackData data); |
51 | 51 |
52 // Handles the next message for this message handler. Should only | 52 // Handles the next message for this message handler. Should only |
53 // be used when not running the handler on the thread pool (via Run | 53 // be used when not running the handler on the thread pool (via Run |
54 // or RunBlocking). | 54 // or RunBlocking). |
55 // | 55 // |
56 // Returns true on success. | 56 // Returns true on success. |
57 MessageStatus HandleNextMessage(); | 57 MessageStatus HandleNextMessage(); |
58 | 58 |
59 // Handles all messages for this message handler. Should only | |
60 // be used when not running the handler on the thread pool (via Run | |
61 // or RunBlocking). | |
62 // | |
63 // Returns true on success. | |
64 MessageStatus HandleAllMessages(); | |
65 | |
59 // Handles any OOB messages for this message handler. Can be used | 66 // Handles any OOB messages for this message handler. Can be used |
60 // even if the message handler is running on the thread pool. | 67 // even if the message handler is running on the thread pool. |
61 // | 68 // |
62 // Returns true on success. | 69 // Returns true on success. |
63 MessageStatus HandleOOBMessages(); | 70 MessageStatus HandleOOBMessages(); |
64 | 71 |
65 // Returns true if there are pending OOB messages for this message | 72 // Returns true if there are pending OOB messages for this message |
66 // handler. | 73 // handler. |
67 bool HasOOBMessages(); | 74 bool HasOOBMessages(); |
68 | 75 |
69 // A message handler tracks how many live ports it has. | 76 // A message handler tracks how many live ports it has. |
70 bool HasLivePorts() const { return live_ports_ > 0; } | 77 bool HasLivePorts() const { return live_ports_ > 0; } |
71 | 78 |
72 intptr_t live_ports() const { | 79 intptr_t live_ports() const { |
73 return live_ports_; | 80 return live_ports_; |
74 } | 81 } |
75 | 82 |
76 bool paused() const { return paused_ > 0; } | 83 bool paused() const { return paused_ > 0; } |
77 | 84 |
78 void increment_paused() { paused_++; } | 85 void increment_paused() { paused_++; } |
79 void decrement_paused() { ASSERT(paused_ > 0); paused_--; } | 86 void decrement_paused() { ASSERT(paused_ > 0); paused_--; } |
80 | 87 |
81 bool pause_on_start() const { | 88 bool ShouldPauseOnStart() const; |
82 return pause_on_start_; | 89 bool should_pause_on_start() const { |
90 return should_pause_on_start_; | |
83 } | 91 } |
84 | 92 |
85 void set_pause_on_start(bool pause_on_start) { | 93 void set_should_pause_on_start(bool should_pause_on_start) { |
86 pause_on_start_ = pause_on_start; | 94 should_pause_on_start_ = should_pause_on_start; |
87 } | 95 } |
88 | 96 |
89 bool paused_on_start() const { | 97 bool is_paused_on_start() const { |
90 // If pause_on_start_ is still set, tell the user we are paused, | 98 // If should_pause_on_start_ is still set, tell the user we are paused, |
91 // even if we haven't hit the pause point yet. | 99 // even if we haven't hit the pause point yet. |
turnidge
2016/02/03 23:17:57
This comment seems out of date. Remove? Problem
Cutch
2016/02/03 23:25:07
Done.
| |
92 return paused_on_start_; | 100 return is_paused_on_start_; |
93 } | 101 } |
94 | 102 |
95 bool pause_on_exit() const { | 103 bool ShouldPauseOnExit() const; |
96 return pause_on_exit_; | 104 bool should_pause_on_exit() const { |
105 return should_pause_on_exit_; | |
97 } | 106 } |
98 | 107 |
99 void set_pause_on_exit(bool pause_on_exit) { | 108 void set_should_pause_on_exit(bool should_pause_on_exit) { |
100 pause_on_exit_ = pause_on_exit; | 109 should_pause_on_exit_ = should_pause_on_exit; |
101 } | 110 } |
102 | 111 |
103 bool paused_on_exit() const { | 112 bool is_paused_on_exit() const { |
104 return paused_on_exit_; | 113 return is_paused_on_exit_; |
105 } | 114 } |
106 | 115 |
107 // Timestamp of the paused on start or paused on exit. | 116 // Timestamp of the paused on start or paused on exit. |
108 int64_t paused_timestamp() const { | 117 int64_t paused_timestamp() const { |
109 return paused_timestamp_; | 118 return paused_timestamp_; |
110 } | 119 } |
111 | 120 |
121 void PausedOnStart(bool paused); | |
122 void PausedOnExit(bool paused); | |
123 | |
112 class AcquiredQueues : public ValueObject { | 124 class AcquiredQueues : public ValueObject { |
113 public: | 125 public: |
114 AcquiredQueues(); | 126 AcquiredQueues(); |
115 | 127 |
116 ~AcquiredQueues(); | 128 ~AcquiredQueues(); |
117 | 129 |
118 MessageQueue* queue() { | 130 MessageQueue* queue() { |
119 if (handler_ == NULL) { | 131 if (handler_ == NULL) { |
120 return NULL; | 132 return NULL; |
121 } | 133 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 Thread* thread() const { return Thread::Current(); } | 208 Thread* thread() const { return Thread::Current(); } |
197 | 209 |
198 private: | 210 private: |
199 friend class PortMap; | 211 friend class PortMap; |
200 friend class MessageHandlerTestPeer; | 212 friend class MessageHandlerTestPeer; |
201 friend class MessageHandlerTask; | 213 friend class MessageHandlerTask; |
202 | 214 |
203 // Called by MessageHandlerTask to process our task queue. | 215 // Called by MessageHandlerTask to process our task queue. |
204 void TaskCallback(); | 216 void TaskCallback(); |
205 | 217 |
218 void PausedOnStartLocked(bool paused); | |
219 void PausedOnExitLocked(bool paused); | |
220 | |
206 // Dequeue the next message. Prefer messages from the oob_queue_ to | 221 // Dequeue the next message. Prefer messages from the oob_queue_ to |
207 // messages from the queue_. | 222 // messages from the queue_. |
208 Message* DequeueMessage(Message::Priority min_priority); | 223 Message* DequeueMessage(Message::Priority min_priority); |
209 | 224 |
210 void ClearOOBQueue(); | 225 void ClearOOBQueue(); |
211 | 226 |
212 // Handles any pending messages. | 227 // Handles any pending messages. |
213 MessageStatus HandleMessages(bool allow_normal_messages, | 228 MessageStatus HandleMessages(bool allow_normal_messages, |
214 bool allow_multiple_normal_messages); | 229 bool allow_multiple_normal_messages); |
215 | 230 |
216 Monitor monitor_; // Protects all fields in MessageHandler. | 231 Monitor monitor_; // Protects all fields in MessageHandler. |
217 MessageQueue* queue_; | 232 MessageQueue* queue_; |
218 MessageQueue* oob_queue_; | 233 MessageQueue* oob_queue_; |
219 // This flag is not thread safe and can only reliably be accessed on a single | 234 // This flag is not thread safe and can only reliably be accessed on a single |
220 // thread. | 235 // thread. |
221 bool oob_message_handling_allowed_; | 236 bool oob_message_handling_allowed_; |
222 intptr_t live_ports_; // The number of open ports, including control ports. | 237 intptr_t live_ports_; // The number of open ports, including control ports. |
223 intptr_t paused_; // The number of pause messages received. | 238 intptr_t paused_; // The number of pause messages received. |
224 bool pause_on_start_; | 239 bool should_pause_on_start_; |
225 bool pause_on_exit_; | 240 bool should_pause_on_exit_; |
226 bool paused_on_start_; | 241 bool is_paused_on_start_; |
227 bool paused_on_exit_; | 242 bool is_paused_on_exit_; |
228 int64_t paused_timestamp_; | 243 int64_t paused_timestamp_; |
229 ThreadPool* pool_; | 244 ThreadPool* pool_; |
230 ThreadPool::Task* task_; | 245 ThreadPool::Task* task_; |
231 StartCallback start_callback_; | 246 StartCallback start_callback_; |
232 EndCallback end_callback_; | 247 EndCallback end_callback_; |
233 CallbackData callback_data_; | 248 CallbackData callback_data_; |
234 | 249 |
235 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 250 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
236 }; | 251 }; |
237 | 252 |
238 } // namespace dart | 253 } // namespace dart |
239 | 254 |
240 #endif // VM_MESSAGE_HANDLER_H_ | 255 #endif // VM_MESSAGE_HANDLER_H_ |
OLD | NEW |