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

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

Issue 19622003: VM Service isolate listing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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_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 typedef enum {
27 kNormalType = 0, // Normal message.
28 kServiceType = 1, // Service isolate message.
siva 2013/07/19 17:41:16 I am not sure about this message type encoding her
29
30 // Iteration.
31 kFirstType = 0,
32 kNumTypes = 2,
33 } Type;
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 // 41 //
33 // If reply_port is kIllegalPort, then there is no reply port. 42 // If reply_port is kIllegalPort, then there is no reply port.
34 Message(Dart_Port dest_port, Dart_Port reply_port, 43 Message(Dart_Port dest_port, Dart_Port reply_port, uint8_t* data,
35 uint8_t* data, intptr_t len, Priority priority) 44 intptr_t len, Priority priority, Type type = kNormalType)
36 : next_(NULL), 45 : next_(NULL),
37 dest_port_(dest_port), 46 dest_port_(dest_port),
38 reply_port_(reply_port), 47 reply_port_(reply_port),
39 data_(data), 48 data_(data),
40 len_(len), 49 len_(len),
41 priority_(priority) {} 50 priority_(priority),
51 type_(type) {}
42 ~Message() { 52 ~Message() {
43 free(data_); 53 free(data_);
44 } 54 }
45 55
46 Dart_Port dest_port() const { return dest_port_; } 56 Dart_Port dest_port() const { return dest_port_; }
47 Dart_Port reply_port() const { return reply_port_; } 57 Dart_Port reply_port() const { return reply_port_; }
48 uint8_t* data() const { return data_; } 58 uint8_t* data() const { return data_; }
49 intptr_t len() const { return len_; } 59 intptr_t len() const { return len_; }
50 Priority priority() const { return priority_; } 60 Priority priority() const { return priority_; }
61 Type type() const { return type_; }
51 62
52 bool IsOOB() const { return priority_ == Message::kOOBPriority; } 63 bool IsOOB() const { return priority_ == Message::kOOBPriority; }
64 bool IsService() const { return type_ == Message::kServiceType; }
53 65
54 private: 66 private:
55 friend class MessageQueue; 67 friend class MessageQueue;
56 68
57 Message* next_; 69 Message* next_;
58 Dart_Port dest_port_; 70 Dart_Port dest_port_;
59 Dart_Port reply_port_; 71 Dart_Port reply_port_;
60 uint8_t* data_; 72 uint8_t* data_;
61 intptr_t len_; 73 intptr_t len_;
62 Priority priority_; 74 Priority priority_;
75 Type type_;
63 76
64 DISALLOW_COPY_AND_ASSIGN(Message); 77 DISALLOW_COPY_AND_ASSIGN(Message);
65 }; 78 };
66 79
67 // There is a message queue per isolate. 80 // There is a message queue per isolate.
68 class MessageQueue { 81 class MessageQueue {
69 public: 82 public:
70 MessageQueue(); 83 MessageQueue();
71 ~MessageQueue(); 84 ~MessageQueue();
72 85
(...skipping 11 matching lines...) Expand all
84 97
85 Message* head_; 98 Message* head_;
86 Message* tail_; 99 Message* tail_;
87 100
88 DISALLOW_COPY_AND_ASSIGN(MessageQueue); 101 DISALLOW_COPY_AND_ASSIGN(MessageQueue);
89 }; 102 };
90 103
91 } // namespace dart 104 } // namespace dart
92 105
93 #endif // VM_MESSAGE_H_ 106 #endif // VM_MESSAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698