| 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_QUEUE_H_ | 5 #ifndef VM_MESSAGE_QUEUE_H_ |
| 6 #define VM_MESSAGE_QUEUE_H_ | 6 #define VM_MESSAGE_QUEUE_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "vm/thread.h" | 9 #include "vm/thread.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 | 42 |
| 43 // There is a message queue per isolate. | 43 // There is a message queue per isolate. |
| 44 class MessageQueue { | 44 class MessageQueue { |
| 45 public: | 45 public: |
| 46 MessageQueue() : head_(NULL), tail_(NULL) {} | 46 MessageQueue() : head_(NULL), tail_(NULL) {} |
| 47 ~MessageQueue(); | 47 ~MessageQueue(); |
| 48 | 48 |
| 49 void Enqueue(PortMessage* msg); | 49 void Enqueue(PortMessage* msg); |
| 50 | 50 |
| 51 // May block if no message is available. | 51 // Gets the next message from the message queue, possibly blocking |
| 52 // if no message is available. 'millis' is a timeout in |
| 53 // milliseconds. If 'millis' is 0, then this means to block |
| 54 // indefinitely. May block if no message is available. May return |
| 55 // NULL even if 'millis' is 0 due to spurious wakeups. |
| 52 PortMessage* Dequeue(int64_t millis); | 56 PortMessage* Dequeue(int64_t millis); |
| 53 | 57 |
| 54 void Flush(Dart_Port port); | 58 void Flush(Dart_Port port); |
| 55 void FlushAll(); | 59 void FlushAll(); |
| 56 | 60 |
| 57 private: | 61 private: |
| 58 friend class MessageQueueTestPeer; | 62 friend class MessageQueueTestPeer; |
| 59 | 63 |
| 60 Monitor monitor_; | 64 Monitor monitor_; |
| 61 PortMessage* head_; | 65 PortMessage* head_; |
| 62 PortMessage* tail_; | 66 PortMessage* tail_; |
| 63 | 67 |
| 64 DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 68 DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 } // namespace dart | 71 } // namespace dart |
| 68 | 72 |
| 69 #endif // VM_MESSAGE_QUEUE_H_ | 73 #endif // VM_MESSAGE_QUEUE_H_ |
| OLD | NEW |