Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: runtime/vm/message_handler.h

Issue 1665773004: Add necessary support functions so that embedders can implemented pause on start and exit (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 normals messages for this message handler. Should only
turnidge 2016/02/03 21:33:37 Delete "normals". This functions actually handles
Cutch 2016/02/03 23:04:05 Done.
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 HandleNormalMessages();
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 pause_on_start() const {
turnidge 2016/02/03 21:33:37 Consider renaming these to match your CL: pause_o
Cutch 2016/02/03 23:04:05 Done.
82 return pause_on_start_; 89 return pause_on_start_;
83 } 90 }
84 91
85 void set_pause_on_start(bool pause_on_start) { 92 void set_pause_on_start(bool pause_on_start) {
86 pause_on_start_ = pause_on_start; 93 pause_on_start_ = pause_on_start;
87 } 94 }
88 95
89 bool paused_on_start() const { 96 bool paused_on_start() const {
90 // If pause_on_start_ is still set, tell the user we are paused, 97 // If pause_on_start_ is still set, tell the user we are paused,
91 // even if we haven't hit the pause point yet. 98 // even if we haven't hit the pause point yet.
(...skipping 10 matching lines...) Expand all
102 109
103 bool paused_on_exit() const { 110 bool paused_on_exit() const {
104 return paused_on_exit_; 111 return paused_on_exit_;
105 } 112 }
106 113
107 // Timestamp of the paused on start or paused on exit. 114 // Timestamp of the paused on start or paused on exit.
108 int64_t paused_timestamp() const { 115 int64_t paused_timestamp() const {
109 return paused_timestamp_; 116 return paused_timestamp_;
110 } 117 }
111 118
119 void PausedOnStart(bool v);
120 void PausedOnExit(bool v);
121
112 class AcquiredQueues : public ValueObject { 122 class AcquiredQueues : public ValueObject {
113 public: 123 public:
114 AcquiredQueues(); 124 AcquiredQueues();
115 125
116 ~AcquiredQueues(); 126 ~AcquiredQueues();
117 127
118 MessageQueue* queue() { 128 MessageQueue* queue() {
119 if (handler_ == NULL) { 129 if (handler_ == NULL) {
120 return NULL; 130 return NULL;
121 } 131 }
(...skipping 22 matching lines...) Expand all
144 154
145 #if defined(DEBUG) 155 #if defined(DEBUG)
146 // Check that it is safe to access this message handler. 156 // Check that it is safe to access this message handler.
147 // 157 //
148 // For example, if this MessageHandler is an isolate, then it is 158 // For example, if this MessageHandler is an isolate, then it is
149 // only safe to access it when the MessageHandler is the current 159 // only safe to access it when the MessageHandler is the current
150 // isolate. 160 // isolate.
151 virtual void CheckAccess(); 161 virtual void CheckAccess();
152 #endif 162 #endif
153 163
164 virtual void NotifyPauseOnStart() {}
165 virtual void NotifyPauseOnExit() {}
166
154 protected: 167 protected:
155 // ------------ START PortMap API ------------ 168 // ------------ START PortMap API ------------
156 // These functions should only be called from the PortMap. 169 // These functions should only be called from the PortMap.
157 170
158 // Does this message handler correspond to the current isolate? 171 // Does this message handler correspond to the current isolate?
159 virtual bool IsCurrentIsolate() const { return false; } 172 virtual bool IsCurrentIsolate() const { return false; }
160 173
161 // Return Isolate to which this message handler corresponds to. 174 // Return Isolate to which this message handler corresponds to.
162 virtual Isolate* isolate() const { return NULL; } 175 virtual Isolate* isolate() const { return NULL; }
163 176
(...skipping 18 matching lines...) Expand all
182 // ------------ END PortMap API ------------ 195 // ------------ END PortMap API ------------
183 196
184 // Custom message notification. Optionally provided by subclass. 197 // Custom message notification. Optionally provided by subclass.
185 virtual void MessageNotify(Message::Priority priority); 198 virtual void MessageNotify(Message::Priority priority);
186 199
187 // Handles a single message. Provided by subclass. 200 // Handles a single message. Provided by subclass.
188 // 201 //
189 // Returns true on success. 202 // Returns true on success.
190 virtual MessageStatus HandleMessage(Message* message) = 0; 203 virtual MessageStatus HandleMessage(Message* message) = 0;
191 204
192 virtual void NotifyPauseOnStart() {}
193 virtual void NotifyPauseOnExit() {}
194
195 // TODO(iposva): Set a local field before entering MessageHandler methods. 205 // TODO(iposva): Set a local field before entering MessageHandler methods.
196 Thread* thread() const { return Thread::Current(); } 206 Thread* thread() const { return Thread::Current(); }
197 207
198 private: 208 private:
199 friend class PortMap; 209 friend class PortMap;
200 friend class MessageHandlerTestPeer; 210 friend class MessageHandlerTestPeer;
201 friend class MessageHandlerTask; 211 friend class MessageHandlerTask;
202 212
203 // Called by MessageHandlerTask to process our task queue. 213 // Called by MessageHandlerTask to process our task queue.
204 void TaskCallback(); 214 void TaskCallback();
205 215
216 void PausedOnStartLocked(bool v);
217 void PausedOnExitLocked(bool v);
218
206 // Dequeue the next message. Prefer messages from the oob_queue_ to 219 // Dequeue the next message. Prefer messages from the oob_queue_ to
207 // messages from the queue_. 220 // messages from the queue_.
208 Message* DequeueMessage(Message::Priority min_priority); 221 Message* DequeueMessage(Message::Priority min_priority);
209 222
210 void ClearOOBQueue(); 223 void ClearOOBQueue();
211 224
212 // Handles any pending messages. 225 // Handles any pending messages.
213 MessageStatus HandleMessages(bool allow_normal_messages, 226 MessageStatus HandleMessages(bool allow_normal_messages,
214 bool allow_multiple_normal_messages); 227 bool allow_multiple_normal_messages);
215 228
(...skipping 15 matching lines...) Expand all
231 StartCallback start_callback_; 244 StartCallback start_callback_;
232 EndCallback end_callback_; 245 EndCallback end_callback_;
233 CallbackData callback_data_; 246 CallbackData callback_data_;
234 247
235 DISALLOW_COPY_AND_ASSIGN(MessageHandler); 248 DISALLOW_COPY_AND_ASSIGN(MessageHandler);
236 }; 249 };
237 250
238 } // namespace dart 251 } // namespace dart
239 252
240 #endif // VM_MESSAGE_HANDLER_H_ 253 #endif // VM_MESSAGE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698