Flutter Engine
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 
5 #include "flutter/lib/ui/isolate_name_server/isolate_name_server.h"
6 
7 namespace flutter {
8 
10 
12 
13 Dart_Port IsolateNameServer::LookupIsolatePortByName(const std::string& name) {
14  std::scoped_lock lock(mutex_);
15  return LookupIsolatePortByNameUnprotected(name);
16 }
17 
18 Dart_Port IsolateNameServer::LookupIsolatePortByNameUnprotected(
19  const std::string& name) {
20  auto port_iterator = port_mapping_.find(name);
21  if (port_iterator != port_mapping_.end()) {
22  return port_iterator->second;
23  }
24  return ILLEGAL_PORT;
25 }
26 
28  const std::string& name) {
29  std::scoped_lock lock(mutex_);
30  if (LookupIsolatePortByNameUnprotected(name) != ILLEGAL_PORT) {
31  // Name is already registered.
32  return false;
33  }
34  port_mapping_[name] = port;
35  return true;
36 }
37 
38 bool IsolateNameServer::RemoveIsolateNameMapping(const std::string& name) {
39  std::scoped_lock lock(mutex_);
40  auto port_iterator = port_mapping_.find(name);
41  if (port_iterator == port_mapping_.end()) {
42  return false;
43  }
44  port_mapping_.erase(port_iterator);
45  return true;
46 }
47 
48 } // namespace flutter
Dart_Port LookupIsolatePortByName(const std::string &name)
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol Prefix for the symbols representing ICU data linked into the Flutter library dart Flags passed directly to the Dart VM without being interpreted by the Flutter shell observatory port
Definition: switches.h:75
bool RegisterIsolatePortWithName(Dart_Port port, const std::string &name)
bool RemoveIsolateNameMapping(const std::string &name)
const char * name
Definition: fuchsia.cc:50