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 "vm/thread.h" | 8 #include "vm/thread.h" |
9 | 9 |
10 // Duplicated from dart_api.h to avoid including the whole header. | 10 // Duplicated from dart_api.h to avoid including the whole header. |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // A port number which is never used. | 26 // A port number which is never used. |
27 static const Dart_Port kIllegalPort = 0; | 27 static const Dart_Port kIllegalPort = 0; |
28 | 28 |
29 // A new message to be sent between two isolates. The data handed to this | 29 // A new message to be sent between two isolates. The data handed to this |
30 // message will be disposed by calling free() once the message object is | 30 // message will be disposed by calling free() once the message object is |
31 // being destructed (after delivery or when the receiving port is closed). | 31 // being destructed (after delivery or when the receiving port is closed). |
32 // | 32 // |
33 // If reply_port is kIllegalPort, then there is no reply port. | 33 // If reply_port is kIllegalPort, then there is no reply port. |
34 Message(Dart_Port dest_port, Dart_Port reply_port, | 34 Message(Dart_Port dest_port, Dart_Port reply_port, |
35 uint8_t* data, Priority priority) | 35 uint8_t* data, intptr_t len, Priority priority) |
36 : next_(NULL), | 36 : next_(NULL), |
37 dest_port_(dest_port), | 37 dest_port_(dest_port), |
38 reply_port_(reply_port), | 38 reply_port_(reply_port), |
39 data_(data), | 39 data_(data), |
| 40 len_(len), |
40 priority_(priority) {} | 41 priority_(priority) {} |
41 ~Message() { | 42 ~Message() { |
42 free(data_); | 43 free(data_); |
43 } | 44 } |
44 | 45 |
45 Dart_Port dest_port() const { return dest_port_; } | 46 Dart_Port dest_port() const { return dest_port_; } |
46 Dart_Port reply_port() const { return reply_port_; } | 47 Dart_Port reply_port() const { return reply_port_; } |
47 uint8_t* data() const { return data_; } | 48 uint8_t* data() const { return data_; } |
| 49 intptr_t len() const { return len_; } |
48 Priority priority() const { return priority_; } | 50 Priority priority() const { return priority_; } |
49 | 51 |
50 bool IsOOB() const { return priority_ == Message::kOOBPriority; } | 52 bool IsOOB() const { return priority_ == Message::kOOBPriority; } |
51 | 53 |
52 private: | 54 private: |
53 friend class MessageQueue; | 55 friend class MessageQueue; |
54 | 56 |
55 Message* next_; | 57 Message* next_; |
56 Dart_Port dest_port_; | 58 Dart_Port dest_port_; |
57 Dart_Port reply_port_; | 59 Dart_Port reply_port_; |
58 uint8_t* data_; | 60 uint8_t* data_; |
| 61 intptr_t len_; |
59 Priority priority_; | 62 Priority priority_; |
60 | 63 |
61 DISALLOW_COPY_AND_ASSIGN(Message); | 64 DISALLOW_COPY_AND_ASSIGN(Message); |
62 }; | 65 }; |
63 | 66 |
64 // There is a message queue per isolate. | 67 // There is a message queue per isolate. |
65 class MessageQueue { | 68 class MessageQueue { |
66 public: | 69 public: |
67 MessageQueue(); | 70 MessageQueue(); |
68 ~MessageQueue(); | 71 ~MessageQueue(); |
(...skipping 12 matching lines...) Expand all Loading... |
81 | 84 |
82 Message* head_; | 85 Message* head_; |
83 Message* tail_; | 86 Message* tail_; |
84 | 87 |
85 DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 88 DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
86 }; | 89 }; |
87 | 90 |
88 } // namespace dart | 91 } // namespace dart |
89 | 92 |
90 #endif // VM_MESSAGE_H_ | 93 #endif // VM_MESSAGE_H_ |
OLD | NEW |