| 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 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class Isolate; | 14 class Isolate; |
| 15 class Message; |
| 15 class Mutex; | 16 class Mutex; |
| 16 class PortMapTestPeer; | 17 class PortMapTestPeer; |
| 17 | 18 |
| 18 class PortMap: public AllStatic { | 19 class PortMap: public AllStatic { |
| 19 public: | 20 public: |
| 20 // Allocate a port in the current isolate and return its VM-global id. | 21 // Allocate a port in the current isolate and return its VM-global id. |
| 21 static Dart_Port CreatePort(); | 22 static Dart_Port CreatePort(); |
| 22 | 23 |
| 23 // Indicates that a port has had a ReceivePort created for it at the | 24 // Indicates that a port has had a ReceivePort created for it at the |
| 24 // dart language level. The port remains live until it is closed. | 25 // dart language level. The port remains live until it is closed. |
| 25 static void SetLive(Dart_Port id); | 26 static void SetLive(Dart_Port id); |
| 26 | 27 |
| 27 // Close the port with id. All pending messages will be dropped. | 28 // Close the port with id. All pending messages will be dropped. |
| 28 static void ClosePort(Dart_Port id); | 29 static void ClosePort(Dart_Port id); |
| 29 | 30 |
| 30 // Close all the ports of the current isolate. | 31 // Close all the ports of the current isolate. |
| 31 static void ClosePorts(); | 32 static void ClosePorts(); |
| 32 | 33 |
| 33 // Enqueues the message in the port with id. Returns false if the port is not | 34 // Enqueues the message in the port with id. Returns false if the port is not |
| 34 // active any longer. | 35 // active any longer. |
| 35 // | 36 // |
| 36 // Claims ownership of the memory pointed to by 'message' and will | 37 // Claims ownership of 'message'. |
| 37 // ensure that free(message) is called. | 38 static bool PostMessage(Message* message); |
| 38 static bool PostMessage(Dart_Port dest_port, | |
| 39 Dart_Port reply_port, | |
| 40 Dart_Message message); | |
| 41 | 39 |
| 42 static void InitOnce(); | 40 static void InitOnce(); |
| 43 | 41 |
| 44 private: | 42 private: |
| 45 friend class dart::PortMapTestPeer; | 43 friend class dart::PortMapTestPeer; |
| 46 | 44 |
| 47 // Mapping between port numbers and isolates. | 45 // Mapping between port numbers and isolates. |
| 48 // Free entries have id == 0 and isolate == NULL. Deleted entries have id == 0 | 46 // Free entries have id == 0 and isolate == NULL. Deleted entries have id == 0 |
| 49 // and isolate == deleted_entry_. | 47 // and isolate == deleted_entry_. |
| 50 typedef struct { | 48 typedef struct { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 73 static intptr_t capacity_; | 71 static intptr_t capacity_; |
| 74 static intptr_t used_; | 72 static intptr_t used_; |
| 75 static intptr_t deleted_; | 73 static intptr_t deleted_; |
| 76 | 74 |
| 77 static Dart_Port next_port_; | 75 static Dart_Port next_port_; |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 } // namespace dart | 78 } // namespace dart |
| 81 | 79 |
| 82 #endif // VM_PORT_H_ | 80 #endif // VM_PORT_H_ |
| OLD | NEW |