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 RUNTIME_VM_MESSAGE_HANDLER_H_ | 5 #ifndef RUNTIME_VM_MESSAGE_HANDLER_H_ |
6 #define RUNTIME_VM_MESSAGE_HANDLER_H_ | 6 #define RUNTIME_VM_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/message.h" | 10 #include "vm/message.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Returns true on success. | 70 // Returns true on success. |
71 MessageStatus HandleOOBMessages(); | 71 MessageStatus HandleOOBMessages(); |
72 | 72 |
73 // Returns true if there are pending OOB messages for this message | 73 // Returns true if there are pending OOB messages for this message |
74 // handler. | 74 // handler. |
75 bool HasOOBMessages(); | 75 bool HasOOBMessages(); |
76 | 76 |
77 // A message handler tracks how many live ports it has. | 77 // A message handler tracks how many live ports it has. |
78 bool HasLivePorts() const { return live_ports_ > 0; } | 78 bool HasLivePorts() const { return live_ports_ > 0; } |
79 | 79 |
80 intptr_t live_ports() const { | 80 intptr_t live_ports() const { return live_ports_; } |
81 return live_ports_; | |
82 } | |
83 | 81 |
84 void DebugDump(); | 82 void DebugDump(); |
85 | 83 |
86 bool paused() const { return paused_ > 0; } | 84 bool paused() const { return paused_ > 0; } |
87 | 85 |
88 void increment_paused() { paused_++; } | 86 void increment_paused() { paused_++; } |
89 void decrement_paused() { ASSERT(paused_ > 0); paused_--; } | 87 void decrement_paused() { |
| 88 ASSERT(paused_ > 0); |
| 89 paused_--; |
| 90 } |
90 | 91 |
91 bool ShouldPauseOnStart(MessageStatus status) const; | 92 bool ShouldPauseOnStart(MessageStatus status) const; |
92 bool should_pause_on_start() const { | 93 bool should_pause_on_start() const { return should_pause_on_start_; } |
93 return should_pause_on_start_; | |
94 } | |
95 | 94 |
96 void set_should_pause_on_start(bool should_pause_on_start) { | 95 void set_should_pause_on_start(bool should_pause_on_start) { |
97 should_pause_on_start_ = should_pause_on_start; | 96 should_pause_on_start_ = should_pause_on_start; |
98 } | 97 } |
99 | 98 |
100 bool is_paused_on_start() const { | 99 bool is_paused_on_start() const { return is_paused_on_start_; } |
101 return is_paused_on_start_; | |
102 } | |
103 | 100 |
104 bool ShouldPauseOnExit(MessageStatus status) const; | 101 bool ShouldPauseOnExit(MessageStatus status) const; |
105 bool should_pause_on_exit() const { | 102 bool should_pause_on_exit() const { return should_pause_on_exit_; } |
106 return should_pause_on_exit_; | |
107 } | |
108 | 103 |
109 void set_should_pause_on_exit(bool should_pause_on_exit) { | 104 void set_should_pause_on_exit(bool should_pause_on_exit) { |
110 should_pause_on_exit_ = should_pause_on_exit; | 105 should_pause_on_exit_ = should_pause_on_exit; |
111 } | 106 } |
112 | 107 |
113 bool is_paused_on_exit() const { | 108 bool is_paused_on_exit() const { return is_paused_on_exit_; } |
114 return is_paused_on_exit_; | |
115 } | |
116 | 109 |
117 // Timestamp of the paused on start or paused on exit. | 110 // Timestamp of the paused on start or paused on exit. |
118 int64_t paused_timestamp() const { | 111 int64_t paused_timestamp() const { return paused_timestamp_; } |
119 return paused_timestamp_; | |
120 } | |
121 | 112 |
122 void PausedOnStart(bool paused); | 113 void PausedOnStart(bool paused); |
123 void PausedOnExit(bool paused); | 114 void PausedOnExit(bool paused); |
124 | 115 |
125 // Gives temporary ownership of |queue| and |oob_queue|. Using this object | 116 // Gives temporary ownership of |queue| and |oob_queue|. Using this object |
126 // has the side effect that no OOB messages will be handled if a stack | 117 // has the side effect that no OOB messages will be handled if a stack |
127 // overflow interrupt is delivered. | 118 // overflow interrupt is delivered. |
128 class AcquiredQueues : public ValueObject { | 119 class AcquiredQueues : public ValueObject { |
129 public: | 120 public: |
130 explicit AcquiredQueues(MessageHandler* handler); | 121 explicit AcquiredQueues(MessageHandler* handler); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 bool allow_normal_messages, | 224 bool allow_normal_messages, |
234 bool allow_multiple_normal_messages); | 225 bool allow_multiple_normal_messages); |
235 | 226 |
236 Monitor monitor_; // Protects all fields in MessageHandler. | 227 Monitor monitor_; // Protects all fields in MessageHandler. |
237 MessageQueue* queue_; | 228 MessageQueue* queue_; |
238 MessageQueue* oob_queue_; | 229 MessageQueue* oob_queue_; |
239 // This flag is not thread safe and can only reliably be accessed on a single | 230 // This flag is not thread safe and can only reliably be accessed on a single |
240 // thread. | 231 // thread. |
241 bool oob_message_handling_allowed_; | 232 bool oob_message_handling_allowed_; |
242 intptr_t live_ports_; // The number of open ports, including control ports. | 233 intptr_t live_ports_; // The number of open ports, including control ports. |
243 intptr_t paused_; // The number of pause messages received. | 234 intptr_t paused_; // The number of pause messages received. |
244 bool should_pause_on_start_; | 235 bool should_pause_on_start_; |
245 bool should_pause_on_exit_; | 236 bool should_pause_on_exit_; |
246 bool is_paused_on_start_; | 237 bool is_paused_on_start_; |
247 bool is_paused_on_exit_; | 238 bool is_paused_on_exit_; |
248 bool delete_me_; | 239 bool delete_me_; |
249 int64_t paused_timestamp_; | 240 int64_t paused_timestamp_; |
250 ThreadPool* pool_; | 241 ThreadPool* pool_; |
251 ThreadPool::Task* task_; | 242 ThreadPool::Task* task_; |
252 StartCallback start_callback_; | 243 StartCallback start_callback_; |
253 EndCallback end_callback_; | 244 EndCallback end_callback_; |
254 CallbackData callback_data_; | 245 CallbackData callback_data_; |
255 | 246 |
256 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 247 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
257 }; | 248 }; |
258 | 249 |
259 } // namespace dart | 250 } // namespace dart |
260 | 251 |
261 #endif // RUNTIME_VM_MESSAGE_HANDLER_H_ | 252 #endif // RUNTIME_VM_MESSAGE_HANDLER_H_ |
OLD | NEW |