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_H_ | 5 #ifndef VM_MESSAGE_H_ |
6 #define VM_MESSAGE_H_ | 6 #define VM_MESSAGE_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 kFirstPriority = 0, | 23 kFirstPriority = 0, |
24 kNumPriorities = 2, | 24 kNumPriorities = 2, |
25 } Priority; | 25 } Priority; |
26 | 26 |
27 // Values defining the type of OOB messages. OOB messages can only be | 27 // Values defining the type of OOB messages. OOB messages can only be |
28 // fixed length arrays where the first element is a Smi with one of the | 28 // fixed length arrays where the first element is a Smi with one of the |
29 // valid values below. | 29 // valid values below. |
30 typedef enum { | 30 typedef enum { |
31 kIllegalOOB = 0, | 31 kIllegalOOB = 0, |
32 kServiceOOBMsg = 1, | 32 kServiceOOBMsg = 1, |
33 kIsolateLibOOBMsg = 2 | 33 kIsolateLibOOBMsg = 2, |
| 34 kDelayedIsolateLibOOBMsg = 3, |
34 } OOBMsgTag; | 35 } OOBMsgTag; |
35 | 36 |
36 // A port number which is never used. | 37 // A port number which is never used. |
37 static const Dart_Port kIllegalPort = 0; | 38 static const Dart_Port kIllegalPort = 0; |
38 | 39 |
39 // A new message to be sent between two isolates. The data handed to this | 40 // A new message to be sent between two isolates. The data handed to this |
40 // message will be disposed by calling free() once the message object is | 41 // message will be disposed by calling free() once the message object is |
41 // being destructed (after delivery or when the receiving port is closed). | 42 // being destructed (after delivery or when the receiving port is closed). |
42 Message(Dart_Port dest_port, | 43 Message(Dart_Port dest_port, |
43 uint8_t* data, | 44 uint8_t* data, |
44 intptr_t len, | 45 intptr_t len, |
45 Priority priority, | 46 Priority priority, |
46 Dart_Port delivery_failure_port = kIllegalPort) | 47 Dart_Port delivery_failure_port = kIllegalPort) |
47 : next_(NULL), | 48 : next_(NULL), |
48 dest_port_(dest_port), | 49 dest_port_(dest_port), |
49 delivery_failure_port_(delivery_failure_port), | 50 delivery_failure_port_(delivery_failure_port), |
50 data_(data), | 51 data_(data), |
51 len_(len), | 52 len_(len), |
52 priority_(priority) { | 53 priority_(priority) { |
53 ASSERT(dest_port != kIllegalPort); | |
54 ASSERT((priority == kNormalPriority) || | 54 ASSERT((priority == kNormalPriority) || |
55 (delivery_failure_port == kIllegalPort)); | 55 (delivery_failure_port == kIllegalPort)); |
56 } | 56 } |
57 ~Message() { | 57 ~Message() { |
58 ASSERT(delivery_failure_port_ == kIllegalPort); | 58 ASSERT(delivery_failure_port_ == kIllegalPort); |
59 free(data_); | 59 free(data_); |
60 } | 60 } |
61 | 61 |
62 Dart_Port dest_port() const { return dest_port_; } | 62 Dart_Port dest_port() const { return dest_port_; } |
63 uint8_t* data() const { return data_; } | 63 uint8_t* data() const { return data_; } |
(...skipping 16 matching lines...) Expand all Loading... |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(Message); | 81 DISALLOW_COPY_AND_ASSIGN(Message); |
82 }; | 82 }; |
83 | 83 |
84 // There is a message queue per isolate. | 84 // There is a message queue per isolate. |
85 class MessageQueue { | 85 class MessageQueue { |
86 public: | 86 public: |
87 MessageQueue(); | 87 MessageQueue(); |
88 ~MessageQueue(); | 88 ~MessageQueue(); |
89 | 89 |
90 void Enqueue(Message* msg); | 90 void Enqueue(Message* msg, bool before_events); |
91 | 91 |
92 // Gets the next message from the message queue or NULL if no | 92 // Gets the next message from the message queue or NULL if no |
93 // message is available. This function will not block. | 93 // message is available. This function will not block. |
94 Message* Dequeue(); | 94 Message* Dequeue(); |
95 | 95 |
96 bool IsEmpty() { return head_ == NULL; } | 96 bool IsEmpty() { return head_ == NULL; } |
97 | 97 |
98 // Clear all messages from the message queue. | 98 // Clear all messages from the message queue. |
99 void Clear(); | 99 void Clear(); |
100 | 100 |
101 private: | 101 private: |
102 Message* head_; | 102 Message* head_; |
103 Message* tail_; | 103 Message* tail_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 105 DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace dart | 108 } // namespace dart |
109 | 109 |
110 #endif // VM_MESSAGE_H_ | 110 #endif // VM_MESSAGE_H_ |
OLD | NEW |