Flutter Engine
 
Loading...
Searching...
No Matches
isolate_name_server.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7namespace flutter {
8
10
12
14 const std::string& name) {
15 std::scoped_lock lock(mutex_);
16 return LookupIsolatePortByNameUnprotected(name);
17}
18
19Dart_PortEx IsolateNameServer::LookupIsolatePortByNameUnprotected(
20 const std::string& name) {
21 auto port_iterator = port_mapping_.find(name);
22 if (port_iterator != port_mapping_.end()) {
23 return port_iterator->second;
24 }
25 return {ILLEGAL_PORT, ILLEGAL_PORT};
26}
27
29 const std::string& name) {
30 std::scoped_lock lock(mutex_);
31 if (LookupIsolatePortByNameUnprotected(name).port_id != ILLEGAL_PORT) {
32 // Name is already registered.
33 return false;
34 }
35 port_mapping_[name] = port;
36 return true;
37}
38
40 std::scoped_lock lock(mutex_);
41 auto port_iterator = port_mapping_.find(name);
42 if (port_iterator == port_mapping_.end()) {
43 return false;
44 }
45 port_mapping_.erase(port_iterator);
46 return true;
47}
48
49} // namespace flutter
bool RegisterIsolatePortWithName(Dart_PortEx port, const std::string &name)
Dart_PortEx LookupIsolatePortByName(const std::string &name)
bool RemoveIsolateNameMapping(const std::string &name)
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27