| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // | 46 // |
| 47 // Returns true on success. | 47 // Returns true on success. |
| 48 bool HandleNextMessage(); | 48 bool HandleNextMessage(); |
| 49 | 49 |
| 50 // Handles any OOB messages for this message handler. Can be used | 50 // Handles any OOB messages for this message handler. Can be used |
| 51 // even if the message handler is running on the thread pool. | 51 // even if the message handler is running on the thread pool. |
| 52 // | 52 // |
| 53 // Returns true on success. | 53 // Returns true on success. |
| 54 bool HandleOOBMessages(); | 54 bool HandleOOBMessages(); |
| 55 | 55 |
| 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 |
| 58 // control ports are open. |
| 59 // Usually either 0 or 1. |
| 60 void increment_control_ports(); |
| 61 void decrement_control_ports(); |
| 62 |
| 56 // A message handler tracks how many live ports it has. | 63 // A message handler tracks how many live ports it has. |
| 57 bool HasLivePorts() const { return live_ports_ > 0; } | 64 bool HasLivePorts() const { return live_ports_ > control_ports_; } |
| 58 | 65 |
| 59 #if defined(DEBUG) | 66 #if defined(DEBUG) |
| 60 // Check that it is safe to access this message handler. | 67 // Check that it is safe to access this message handler. |
| 61 // | 68 // |
| 62 // For example, if this MessageHandler is an isolate, then it is | 69 // For example, if this MessageHandler is an isolate, then it is |
| 63 // only safe to access it when the MessageHandler is the current | 70 // only safe to access it when the MessageHandler is the current |
| 64 // isolate. | 71 // isolate. |
| 65 virtual void CheckAccess(); | 72 virtual void CheckAccess(); |
| 66 #endif | 73 #endif |
| 67 | 74 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // messages from the queue_. | 120 // messages from the queue_. |
| 114 Message* DequeueMessage(Message::Priority min_priority); | 121 Message* DequeueMessage(Message::Priority min_priority); |
| 115 | 122 |
| 116 // Handles any pending messages. | 123 // Handles any pending messages. |
| 117 bool HandleMessages(bool allow_normal_messages, | 124 bool HandleMessages(bool allow_normal_messages, |
| 118 bool allow_multiple_normal_messages); | 125 bool allow_multiple_normal_messages); |
| 119 | 126 |
| 120 Monitor monitor_; // Protects all fields in MessageHandler. | 127 Monitor monitor_; // Protects all fields in MessageHandler. |
| 121 MessageQueue* queue_; | 128 MessageQueue* queue_; |
| 122 MessageQueue* oob_queue_; | 129 MessageQueue* oob_queue_; |
| 123 intptr_t live_ports_; | 130 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. |
| 124 ThreadPool* pool_; | 132 ThreadPool* pool_; |
| 125 ThreadPool::Task* task_; | 133 ThreadPool::Task* task_; |
| 126 StartCallback start_callback_; | 134 StartCallback start_callback_; |
| 127 EndCallback end_callback_; | 135 EndCallback end_callback_; |
| 128 CallbackData callback_data_; | 136 CallbackData callback_data_; |
| 129 | 137 |
| 130 DISALLOW_COPY_AND_ASSIGN(MessageHandler); | 138 DISALLOW_COPY_AND_ASSIGN(MessageHandler); |
| 131 }; | 139 }; |
| 132 | 140 |
| 133 } // namespace dart | 141 } // namespace dart |
| 134 | 142 |
| 135 #endif // VM_MESSAGE_HANDLER_H_ | 143 #endif // VM_MESSAGE_HANDLER_H_ |
| OLD | NEW |