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
14#include "flutter/fml/closure.h"
17
18namespace flutter {
19
20class DartIsolate;
21class DartSnapshot;
23
24using ChildIsolatePreparer = std::function<bool(DartIsolate*)>;
25
26// Object holding state associated with a Dart isolate group. An instance of
27// this class will be provided to Dart_CreateIsolateGroup as the
28// isolate_group_data.
29//
30// This object must be thread safe because the Dart VM can invoke the isolate
31// group cleanup callback on any thread.
33 public:
35 const Settings& settings,
36 fml::RefPtr<const DartSnapshot> isolate_snapshot,
37 std::string advisory_script_uri,
38 std::string advisory_script_entrypoint,
39 const ChildIsolatePreparer& child_isolate_preparer,
40 const fml::closure& isolate_create_callback,
41 const fml::closure& isolate_shutdown_callback,
42 std::shared_ptr<NativeAssetsManager> native_assets_manager = nullptr);
43
45
46 const Settings& GetSettings() const;
47
49
50 const std::string& GetAdvisoryScriptURI() const;
51
52 const std::string& GetAdvisoryScriptEntrypoint() const;
53
55
57
59
61
62 std::shared_ptr<NativeAssetsManager> GetNativeAssetsManager() const;
63
64 /// Adds a kernel buffer mapping to the kernels loaded for this isolate group.
65 void AddKernelBuffer(const std::shared_ptr<const fml::Mapping>& buffer);
66
67 /// A copy of the mappings for all kernel buffer objects loaded into this
68 /// isolate group.
69 std::vector<std::shared_ptr<const fml::Mapping>> GetKernelBuffers() const;
70
71 // |PlatformMessageHandlerStorage|
73 int64_t root_isolate_token,
74 std::weak_ptr<PlatformMessageHandler> handler) override;
75
76 // |PlatformMessageHandlerStorage|
77 std::weak_ptr<PlatformMessageHandler> GetPlatformMessageHandler(
78 int64_t root_isolate_token) const override;
79
80 private:
81 std::vector<std::shared_ptr<const fml::Mapping>> kernel_buffers_;
82 const Settings settings_;
83 const fml::RefPtr<const DartSnapshot> isolate_snapshot_;
84 const std::string advisory_script_uri_;
85 const std::string advisory_script_entrypoint_;
86 mutable std::mutex child_isolate_preparer_mutex_;
87 ChildIsolatePreparer child_isolate_preparer_;
88 const fml::closure isolate_create_callback_;
89 const fml::closure isolate_shutdown_callback_;
90 std::shared_ptr<NativeAssetsManager> native_assets_manager_;
91 std::map<int64_t, std::weak_ptr<PlatformMessageHandler>>
92 platform_message_handlers_;
93 mutable std::mutex platform_message_handlers_mutex_;
94
96};
97
98} // namespace flutter
99
100#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
std::shared_ptr< NativeAssetsManager > GetNativeAssetsManager() 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....
const gchar FlBinaryMessengerMessageHandler handler
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::function< bool(DartIsolate *)> ChildIsolatePreparer
std::function< void()> closure
Definition closure.h:14