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_PORT_H_ | 5 #ifndef VM_PORT_H_ |
6 #define VM_PORT_H_ | 6 #define VM_PORT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 11 #include "vm/json_stream.h" |
11 #include "vm/random.h" | 12 #include "vm/random.h" |
12 | 13 |
13 namespace dart { | 14 namespace dart { |
14 | 15 |
15 class Isolate; | 16 class Isolate; |
16 class Message; | 17 class Message; |
17 class MessageHandler; | 18 class MessageHandler; |
18 class Mutex; | 19 class Mutex; |
19 class PortMapTestPeer; | 20 class PortMapTestPeer; |
20 | 21 |
21 class PortMap: public AllStatic { | 22 class PortMap : public AllStatic { |
22 public: | 23 public: |
23 enum PortState { | 24 enum PortState { |
24 kNewPort = 0, // a newly allocated port | 25 kNewPort = 0, // a newly allocated port |
25 kLivePort = 1, // a regular port (has a ReceivePort) | 26 kLivePort = 1, // a regular port (has a ReceivePort) |
26 kControlPort = 2, // a special control port (has a ReceivePort) | 27 kControlPort = 2, // a special control port (has a ReceivePort) |
27 }; | 28 }; |
28 | 29 |
29 // Allocate a port for the provided handler and return its VM-global id. | 30 // Allocate a port for the provided handler and return its VM-global id. |
30 static Dart_Port CreatePort(MessageHandler* handler); | 31 static Dart_Port CreatePort(MessageHandler* handler); |
31 | 32 |
(...skipping 16 matching lines...) Expand all Loading... |
48 static bool PostMessage(Message* message); | 49 static bool PostMessage(Message* message); |
49 | 50 |
50 // Returns whether a port is local to the current isolate. | 51 // Returns whether a port is local to the current isolate. |
51 static bool IsLocalPort(Dart_Port id); | 52 static bool IsLocalPort(Dart_Port id); |
52 | 53 |
53 // Returns the owning Isolate for port 'id'. | 54 // Returns the owning Isolate for port 'id'. |
54 static Isolate* GetIsolate(Dart_Port id); | 55 static Isolate* GetIsolate(Dart_Port id); |
55 | 56 |
56 static void InitOnce(); | 57 static void InitOnce(); |
57 | 58 |
| 59 static void PrintPortsForMessageHandler(MessageHandler* handler, |
| 60 JSONStream* stream); |
| 61 |
58 private: | 62 private: |
59 friend class dart::PortMapTestPeer; | 63 friend class dart::PortMapTestPeer; |
60 | 64 |
61 // Mapping between port numbers and handlers. | 65 // Mapping between port numbers and handlers. |
62 // | 66 // |
63 // Free entries have id == 0 and handler == NULL. Deleted entries | 67 // Free entries have id == 0 and handler == NULL. Deleted entries |
64 // have id == 0 and handler == deleted_entry_. | 68 // have id == 0 and handler == deleted_entry_. |
65 typedef struct { | 69 typedef struct { |
66 Dart_Port port; | 70 Dart_Port port; |
67 MessageHandler* handler; | 71 MessageHandler* handler; |
(...skipping 22 matching lines...) Expand all Loading... |
90 static intptr_t capacity_; | 94 static intptr_t capacity_; |
91 static intptr_t used_; | 95 static intptr_t used_; |
92 static intptr_t deleted_; | 96 static intptr_t deleted_; |
93 | 97 |
94 static Random* prng_; | 98 static Random* prng_; |
95 }; | 99 }; |
96 | 100 |
97 } // namespace dart | 101 } // namespace dart |
98 | 102 |
99 #endif // VM_PORT_H_ | 103 #endif // VM_PORT_H_ |
OLD | NEW |