#include <port.h>
Definition at line 24 of file port.h.
◆ Cleanup()
void dart::PortMap::Cleanup |
( |
| ) |
|
|
static |
Definition at line 261 of file port.cc.
261 {
262 ASSERT(ports_ !=
nullptr);
264 for (
auto it = ports_->
begin(); it != ports_->
end(); ++it) {
265 const auto& entry = *it;
266 ASSERT(entry.handler !=
nullptr);
267 delete entry.handler;
268 it.Delete();
269 }
271
272
273 MutexLocker ml(mutex_);
274 delete prng_;
275 prng_ = nullptr;
276 delete ports_;
277 ports_ = nullptr;
278}
DART_FORCE_INLINE Iterator begin()
DART_FORCE_INLINE Iterator end()
◆ ClosePort()
Definition at line 90 of file port.cc.
90 {
91 if (message_handler != nullptr) *message_handler = nullptr;
92
94 {
95 MutexLocker ml(mutex_);
96 if (ports_ == nullptr) {
97 return false;
98 }
100 if (it == ports_->
end()) {
101 return false;
102 }
104 handler = entry.handler;
105 ASSERT(handler !=
nullptr);
106
107#if defined(DEBUG)
108 handler->CheckAccess();
109#endif
110
111
112
113 it.Delete();
115
116
117
118 auto isolate_it = handler->ports_.TryLookup(
port);
119 ASSERT(isolate_it != handler->ports_.end());
120 isolate_it.Delete();
121 handler->ports_.Rebalance();
122 }
123 handler->ClosePort(
port);
124 if (message_handler != nullptr) *message_handler = handler;
125 return true;
126}
Iterator TryLookup(Dart_Port port)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service port
std::function< void(const T &message, const MessageReply< T > &reply)> MessageHandler
◆ ClosePorts()
Definition at line 128 of file port.cc.
128 {
129 {
130 MutexLocker ml(mutex_);
131 if (ports_ == nullptr) {
132 return;
133 }
134
135
136 for (auto isolate_it = handler->ports_.begin();
137 isolate_it != handler->ports_.end(); ++isolate_it) {
138 auto it = ports_->
TryLookup((*isolate_it).port);
141 ASSERT(entry.port == (*isolate_it).port);
142 ASSERT(entry.handler == handler);
143 it.Delete();
144 isolate_it.Delete();
145 }
146 ASSERT(handler->ports_.IsEmpty());
148 }
149 handler->CloseAllPorts();
150}
◆ CreatePort()
Definition at line 55 of file port.cc.
55 {
56 ASSERT(handler !=
nullptr);
57 MutexLocker ml(mutex_);
58 if (ports_ == nullptr) {
60 }
61
62#if defined(DEBUG)
63 handler->CheckAccess();
64#endif
65
67
68
69
70 MessageHandler::PortSetEntry isolate_entry;
71 isolate_entry.port =
port;
72 handler->ports_.Insert(isolate_entry);
73
76 entry.handler = handler;
78
79 if (FLAG_trace_isolates) {
81 "[+] Opening port: \n"
82 "\thandler: %s\n"
83 "\tport: %" Pd64 "\n",
84 handler->name(), entry.port);
85 }
86
87 return entry.port;
88}
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
void Insert(const T &entry)
◆ DebugDumpForMessageHandler()
void dart::PortMap::DebugDumpForMessageHandler |
( |
MessageHandler * |
handler | ) |
|
|
static |
Definition at line 305 of file port.cc.
305 {
306 SafepointMutexLocker ml(mutex_);
307 if (ports_ == nullptr) {
308 return;
309 }
311 for (auto& entry : *ports_) {
312 if (entry.handler == handler) {
315 OS::PrintErr(
"Handler = %s\n", msg_handler.ToCString());
316 }
317 }
318}
static ObjectPtr LookupHandler(Dart_Port port_id)
◆ GetIsolate()
Definition at line 181 of file port.cc.
181 {
182 MutexLocker ml(mutex_);
183 if (ports_ == nullptr) {
184 return nullptr;
185 }
187 if (it == ports_->
end()) {
188
189 return nullptr;
190 }
191
193 return handler->isolate();
194}
◆ GetOriginId()
Definition at line 196 of file port.cc.
196 {
197 MutexLocker ml(mutex_);
198 if (ports_ == nullptr) {
200 }
202 if (it == ports_->
end()) {
203
205 }
206
208 Isolate* isolate = handler->isolate();
209 if (isolate == nullptr) {
210
212 }
213 return isolate->origin_id();
214}
◆ Init()
void dart::PortMap::Init |
( |
| ) |
|
|
static |
Definition at line 248 of file port.cc.
248 {
249 if (mutex_ == nullptr) {
250 mutex_ = new Mutex();
251 }
252 ASSERT(mutex_ !=
nullptr);
253 if (prng_ == nullptr) {
254 prng_ = new Random();
255 }
256 if (ports_ == nullptr) {
257 ports_ = new PortSet<Entry>();
258 }
259}
◆ IsReceiverInThisIsolateGroupOrClosed()
Definition at line 228 of file port.cc.
229 {
230 MutexLocker ml(mutex_);
231 if (ports_ == nullptr) {
232
233 return true;
234 }
236 if (it == ports_->
end()) {
237
238 return true;
239 }
240 auto isolate = (*it).handler->isolate();
241 if (isolate == nullptr) {
242
243 return false;
244 }
245 return isolate->group() ==
group;
246}
◆ PostMessage()
bool dart::PortMap::PostMessage |
( |
std::unique_ptr< Message > |
message, |
|
|
bool |
before_events = false |
|
) |
| |
|
static |
Definition at line 152 of file port.cc.
153 {
154 MutexLocker ml(mutex_);
155 if (ports_ == nullptr) {
156 return false;
157 }
159 if (it == ports_->
end()) {
160
162 return false;
163 }
165 ASSERT(handler !=
nullptr);
166 handler->PostMessage(std::move(
message), before_events);
167 return true;
168}
◆ PrintPortsForMessageHandler()
Definition at line 280 of file port.cc.
281 {
282#ifndef PRODUCT
284 jsobj.AddProperty("type", "_Ports");
286 {
287 JSONArray ports(&jsobj, "ports");
288 SafepointMutexLocker ml(mutex_);
289 if (ports_ == nullptr) {
290 return;
291 }
292 for (auto& entry : *ports_) {
293 if (entry.handler == handler) {
294 JSONObject
port(&ports);
295 port.AddProperty(
"type",
"_Port");
296 port.AddPropertyF(
"name",
"Isolate Port (%" Pd64 ")", entry.port);
298 port.AddProperty(
"handler", msg_handler);
299 }
300 }
301 }
302#endif
303}
The documentation for this class was generated from the following files:
- third_party/dart-lang/sdk/runtime/vm/port.h
- third_party/dart-lang/sdk/runtime/vm/port.cc