Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dart_isolate_group_data.h
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#ifndef FLUTTER_RUNTIME_DART_ISOLATE_GROUP_DATA_H_
6#define FLUTTER_RUNTIME_DART_ISOLATE_GROUP_DATA_H_
7
8#include <map>
9#include <mutex>
10#include <string>
11
12#include "flutter/common/settings.h"
13#include "flutter/fml/closure.h"
14#include "flutter/fml/memory/ref_ptr.h"
15#include "flutter/lib/ui/window/platform_configuration.h"
16
17namespace flutter {
18
19class DartIsolate;
20class DartSnapshot;
22
23using ChildIsolatePreparer = std::function<bool(DartIsolate*)>;
24
25// Object holding state associated with a Dart isolate group. An instance of
26// this class will be provided to Dart_CreateIsolateGroup as the
27// isolate_group_data.
28//
29// This object must be thread safe because the Dart VM can invoke the isolate
30// group cleanup callback on any thread.
32 public:
33 DartIsolateGroupData(const Settings& settings,
34 fml::RefPtr<const DartSnapshot> isolate_snapshot,
35 std::string advisory_script_uri,
36 std::string advisory_script_entrypoint,
37 const ChildIsolatePreparer& child_isolate_preparer,
38 const fml::closure& isolate_create_callback,
39 const fml::closure& isolate_shutdown_callback);
40
42
43 const Settings& GetSettings() const;
44
46
47 const std::string& GetAdvisoryScriptURI() const;
48
49 const std::string& GetAdvisoryScriptEntrypoint() const;
50
52
54
56
58
59 /// Adds a kernel buffer mapping to the kernels loaded for this isolate group.
60 void AddKernelBuffer(const std::shared_ptr<const fml::Mapping>& buffer);
61
62 /// A copy of the mappings for all kernel buffer objects loaded into this
63 /// isolate group.
64 std::vector<std::shared_ptr<const fml::Mapping>> GetKernelBuffers() const;
65
66 // |PlatformMessageHandlerStorage|
68 int64_t root_isolate_token,
69 std::weak_ptr<PlatformMessageHandler> handler) override;
70
71 // |PlatformMessageHandlerStorage|
72 std::weak_ptr<PlatformMessageHandler> GetPlatformMessageHandler(
73 int64_t root_isolate_token) const override;
74
75 private:
76 std::vector<std::shared_ptr<const fml::Mapping>> kernel_buffers_;
77 const Settings settings_;
78 const fml::RefPtr<const DartSnapshot> isolate_snapshot_;
79 const std::string advisory_script_uri_;
80 const std::string advisory_script_entrypoint_;
81 mutable std::mutex child_isolate_preparer_mutex_;
82 ChildIsolatePreparer child_isolate_preparer_;
83 const fml::closure isolate_create_callback_;
84 const fml::closure isolate_shutdown_callback_;
85 std::map<int64_t, std::weak_ptr<PlatformMessageHandler>>
86 platform_message_handlers_;
87 mutable std::mutex platform_message_handlers_mutex_;
88
90};
91
92} // namespace flutter
93
94#endif // FLUTTER_RUNTIME_DART_ISOLATE_GROUP_DATA_H_
fml::RefPtr< const DartSnapshot > GetIsolateSnapshot() const
const fml::closure & GetIsolateShutdownCallback() const
std::vector< std::shared_ptr< const fml::Mapping > > GetKernelBuffers() const
const std::string & GetAdvisoryScriptURI() const
const std::string & GetAdvisoryScriptEntrypoint() const
void SetChildIsolatePreparer(const ChildIsolatePreparer &value)
std::weak_ptr< PlatformMessageHandler > GetPlatformMessageHandler(int64_t root_isolate_token) const override
ChildIsolatePreparer GetChildIsolatePreparer() const
void SetPlatformMessageHandler(int64_t root_isolate_token, std::weak_ptr< PlatformMessageHandler > handler) override
const fml::closure & GetIsolateCreateCallback() const
void AddKernelBuffer(const std::shared_ptr< const fml::Mapping > &buffer)
Adds a kernel buffer mapping to the kernels loaded for this isolate group.
Represents an instance of a live isolate. An isolate is a separate Dart execution context....
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
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 A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition switches.h:126
std::function< bool(DartIsolate *)> ChildIsolatePreparer
std::function< void()> closure
Definition closure.h:14