Chromium Code Reviews| 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. |
| 11 typedef int64_t Dart_Port; | 11 typedef int64_t Dart_Port; |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class Message { | 15 class Message { |
| 16 public: | 16 public: |
| 17 typedef enum { | 17 typedef enum { |
| 18 kNormalPriority = 0, // Deliver message when idle. | 18 kNormalPriority = 0, // Deliver message when idle. |
| 19 kOOBPriority = 1, // Deliver message asap. | 19 kOOBPriority = 1, // Deliver message asap. |
| 20 | 20 |
| 21 // Iteration. | 21 // Iteration. |
| 22 kFirstPriority = 0, | 22 kFirstPriority = 0, |
| 23 kNumPriorities = 2, | 23 kNumPriorities = 2, |
| 24 } Priority; | 24 } Priority; |
| 25 | 25 |
| 26 // Values defining the type of OOB messages. OOB messages can only be | |
| 27 // fixed length arrays where the first element is a Smi with one of the | |
| 28 // valid values below. | |
| 29 typedef enum { | |
| 30 kIllegalOOB = 0, | |
| 31 kServiceOOBMsg = 1, | |
| 32 kIsolateLibOOBMsg = 2 | |
| 33 } OOBMsgTag; | |
| 34 | |
| 26 // A port number which is never used. | 35 // A port number which is never used. |
| 27 static const Dart_Port kIllegalPort = 0; | 36 static const Dart_Port kIllegalPort = 0; |
| 28 | 37 |
| 29 // A new message to be sent between two isolates. The data handed to this | 38 // 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 | 39 // message will be disposed by calling free() once the message object is |
| 31 // being destructed (after delivery or when the receiving port is closed). | 40 // being destructed (after delivery or when the receiving port is closed). |
| 32 Message(Dart_Port dest_port, uint8_t* data, intptr_t len, Priority priority) | 41 Message(Dart_Port dest_port, |
| 42 uint8_t* data, | |
| 43 intptr_t len, | |
| 44 Priority priority, | |
| 45 Dart_Port delivery_failure_port = kIllegalPort) | |
|
Ivan Posva
2014/05/28 21:02:31
The setting of this value is not hooked up yet. Th
| |
| 33 : next_(NULL), | 46 : next_(NULL), |
| 34 dest_port_(dest_port), | 47 dest_port_(dest_port), |
| 48 delivery_failure_port_(delivery_failure_port), | |
| 35 data_(data), | 49 data_(data), |
| 36 len_(len), | 50 len_(len), |
| 37 priority_(priority) { | 51 priority_(priority) { |
| 38 ASSERT(dest_port != kIllegalPort); | 52 ASSERT(dest_port != kIllegalPort); |
| 39 } | 53 } |
| 40 ~Message() { | 54 ~Message() { |
| 55 ASSERT(delivery_failure_port_ == kIllegalPort); | |
| 41 free(data_); | 56 free(data_); |
| 42 } | 57 } |
| 43 | 58 |
| 44 Dart_Port dest_port() const { return dest_port_; } | 59 Dart_Port dest_port() const { return dest_port_; } |
| 45 uint8_t* data() const { return data_; } | 60 uint8_t* data() const { return data_; } |
| 46 intptr_t len() const { return len_; } | 61 intptr_t len() const { return len_; } |
| 47 Priority priority() const { return priority_; } | 62 Priority priority() const { return priority_; } |
| 48 | 63 |
| 49 bool IsOOB() const { return priority_ == Message::kOOBPriority; } | 64 bool IsOOB() const { return priority_ == Message::kOOBPriority; } |
| 50 | 65 |
| 66 bool RedirectToDeliveryFailurePort(); | |
| 67 | |
| 51 private: | 68 private: |
| 52 friend class MessageQueue; | 69 friend class MessageQueue; |
| 53 | 70 |
| 54 Message* next_; | 71 Message* next_; |
| 55 Dart_Port dest_port_; | 72 Dart_Port dest_port_; |
| 73 Dart_Port delivery_failure_port_; | |
| 56 uint8_t* data_; | 74 uint8_t* data_; |
| 57 intptr_t len_; | 75 intptr_t len_; |
| 58 Priority priority_; | 76 Priority priority_; |
| 59 | 77 |
| 60 DISALLOW_COPY_AND_ASSIGN(Message); | 78 DISALLOW_COPY_AND_ASSIGN(Message); |
| 61 }; | 79 }; |
| 62 | 80 |
| 63 // There is a message queue per isolate. | 81 // There is a message queue per isolate. |
| 64 class MessageQueue { | 82 class MessageQueue { |
| 65 public: | 83 public: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 80 | 98 |
| 81 Message* head_; | 99 Message* head_; |
| 82 Message* tail_; | 100 Message* tail_; |
| 83 | 101 |
| 84 DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 102 DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
| 85 }; | 103 }; |
| 86 | 104 |
| 87 } // namespace dart | 105 } // namespace dart |
| 88 | 106 |
| 89 #endif // VM_MESSAGE_H_ | 107 #endif // VM_MESSAGE_H_ |
| OLD | NEW |