Flutter Engine
The Flutter Engine
|
Specifies all the configuration required by the runtime library to launch the root isolate. This object may be created on any thread but must be given to the |Run| call of the |Engine| on the UI thread. The configuration object is used to specify how the root isolate finds its snapshots, assets, root library and the "main" entrypoint. More...
#include <run_configuration.h>
Public Member Functions | |
RunConfiguration (std::unique_ptr< IsolateConfiguration > configuration) | |
Creates a run configuration with only an isolate configuration. There is no asset manager and default entrypoint and root library are used ("main" in root library). More... | |
RunConfiguration (std::unique_ptr< IsolateConfiguration > configuration, std::shared_ptr< AssetManager > asset_manager) | |
Creates a run configuration with the specified isolate configuration and asset manager. The default entrypoint and root library are used ("main" in root library). More... | |
RunConfiguration (RunConfiguration &&config) | |
Run configurations cannot be copied because it may not always be possible to copy the underlying isolate snapshots. If multiple run configurations share the same underlying snapshots, creating a configuration from isolate snapshots sharing the same underlying buffers is recommended. More... | |
~RunConfiguration () | |
There are no threading restrictions on the destruction of the run configuration. More... | |
bool | IsValid () const |
A valid run configuration only guarantees that the engine should be able to find the assets and the isolate snapshots when it attempts to launch the root isolate. The validity of the snapshot cannot be determined yet. That determination can only be made when the configuration is used to run the root isolate in the engine. However, the engine will always reject an invalid run configuration. More... | |
bool | AddAssetResolver (std::unique_ptr< AssetResolver > resolver) |
Asset managers maintain a list of resolvers that are checked in order when attempting to locate an asset. This method adds a resolver to the end of the list. More... | |
void | SetEntrypoint (std::string entrypoint) |
Updates the main application entrypoint. If this is not set, the "main" method is used as the entrypoint. More... | |
void | SetEntrypointAndLibrary (std::string entrypoint, std::string library) |
Specifies the main Dart entrypoint and the library to find that entrypoint in. By default, this is the "main" method in the root library. The root library may be specified by entering the empty string as the second argument. More... | |
void | SetEntrypointArgs (std::vector< std::string > entrypoint_args) |
Updates the main application entrypoint arguments. More... | |
std::shared_ptr< AssetManager > | GetAssetManager () const |
const std::string & | GetEntrypoint () const |
const std::string & | GetEntrypointLibrary () const |
const std::vector< std::string > & | GetEntrypointArgs () const |
std::unique_ptr< IsolateConfiguration > | TakeIsolateConfiguration () |
The engine uses this to take the isolate configuration from the run configuration. The run configuration is no longer valid after this call is made. The non-copyable nature of some of the snapshots referenced in the isolate configuration is why the run configuration as a whole is not copyable. More... | |
Static Public Member Functions | |
static RunConfiguration | InferFromSettings (const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup) |
Attempts to infer a run configuration from the settings object. This tries to create a run configuration with sensible defaults for the given Dart VM runtime mode. In JIT mode, this will attempt to look for the VM and isolate snapshots in the assets directory (must be specified in settings). In AOT mode, it will attempt to look for known snapshot symbols in the currently loaded process. The entrypoint defaults to the "main" method in the root library. More... | |
Specifies all the configuration required by the runtime library to launch the root isolate. This object may be created on any thread but must be given to the |Run| call of the |Engine| on the UI thread. The configuration object is used to specify how the root isolate finds its snapshots, assets, root library and the "main" entrypoint.
Definition at line 29 of file run_configuration.h.
|
explicit |
Creates a run configuration with only an isolate configuration. There is no asset manager and default entrypoint and root library are used ("main" in root library).
[in] | configuration | The configuration |
Definition at line 40 of file run_configuration.cc.
flutter::RunConfiguration::RunConfiguration | ( | std::unique_ptr< IsolateConfiguration > | configuration, |
std::shared_ptr< AssetManager > | asset_manager | ||
) |
Creates a run configuration with the specified isolate configuration and asset manager. The default entrypoint and root library are used ("main" in root library).
[in] | configuration | The configuration |
[in] | asset_manager | The asset manager |
Definition at line 49 of file run_configuration.cc.
|
default |
Run configurations cannot be copied because it may not always be possible to copy the underlying isolate snapshots. If multiple run configurations share the same underlying snapshots, creating a configuration from isolate snapshots sharing the same underlying buffers is recommended.
config | The run configuration to move. |
|
default |
There are no threading restrictions on the destruction of the run configuration.
bool flutter::RunConfiguration::AddAssetResolver | ( | std::unique_ptr< AssetResolver > | resolver | ) |
Asset managers maintain a list of resolvers that are checked in order when attempting to locate an asset. This method adds a resolver to the end of the list.
[in] | resolver | The asset resolver to add to the engine of the list resolvers maintained by the asset manager. |
Definition at line 67 of file run_configuration.cc.
std::shared_ptr< AssetManager > flutter::RunConfiguration::GetAssetManager | ( | ) | const |
Definition at line 92 of file run_configuration.cc.
const std::string & flutter::RunConfiguration::GetEntrypoint | ( | ) | const |
Definition at line 96 of file run_configuration.cc.
const std::vector< std::string > & flutter::RunConfiguration::GetEntrypointArgs | ( | ) | const |
Definition at line 104 of file run_configuration.cc.
const std::string & flutter::RunConfiguration::GetEntrypointLibrary | ( | ) | const |
Definition at line 100 of file run_configuration.cc.
|
static |
Attempts to infer a run configuration from the settings object. This tries to create a run configuration with sensible defaults for the given Dart VM runtime mode. In JIT mode, this will attempt to look for the VM and isolate snapshots in the assets directory (must be specified in settings). In AOT mode, it will attempt to look for known snapshot symbols in the currently loaded process. The entrypoint defaults to the "main" method in the root library.
[in] | settings | The settings object used to look for the various snapshots and settings. This is usually initialized from command line arguments. |
[in] | io_worker | An optional IO worker. Resolving and reading the various snapshots may be slow. Providing an IO worker will ensure that realization of these snapshots happens on a worker thread instead of the calling thread. Note that the work done to realize the snapshots may occur after this call returns. If is the embedder's responsibility to make sure the serial worker is kept alive for the lifetime of the shell associated with the engine that this run configuration is given to. |
[in] | launch_type | Whether to launch the new isolate into an existing group or a new one. |
Definition at line 19 of file run_configuration.cc.
bool flutter::RunConfiguration::IsValid | ( | ) | const |
A valid run configuration only guarantees that the engine should be able to find the assets and the isolate snapshots when it attempts to launch the root isolate. The validity of the snapshot cannot be determined yet. That determination can only be made when the configuration is used to run the root isolate in the engine. However, the engine will always reject an invalid run configuration.
Definition at line 63 of file run_configuration.cc.
void flutter::RunConfiguration::SetEntrypoint | ( | std::string | entrypoint | ) |
Updates the main application entrypoint. If this is not set, the "main" method is used as the entrypoint.
[in] | entrypoint | The entrypoint to use. |
Definition at line 77 of file run_configuration.cc.
void flutter::RunConfiguration::SetEntrypointAndLibrary | ( | std::string | entrypoint, |
std::string | library | ||
) |
Specifies the main Dart entrypoint and the library to find that entrypoint in. By default, this is the "main" method in the root library. The root library may be specified by entering the empty string as the second argument.
[in] | entrypoint | The entrypoint |
[in] | library | The library |
Definition at line 81 of file run_configuration.cc.
void flutter::RunConfiguration::SetEntrypointArgs | ( | std::vector< std::string > | entrypoint_args | ) |
Updates the main application entrypoint arguments.
[in] | entrypoint_args | The entrypoint arguments to use. |
Definition at line 87 of file run_configuration.cc.
std::unique_ptr< IsolateConfiguration > flutter::RunConfiguration::TakeIsolateConfiguration | ( | ) |
The engine uses this to take the isolate configuration from the run configuration. The run configuration is no longer valid after this call is made. The non-copyable nature of some of the snapshots referenced in the isolate configuration is why the run configuration as a whole is not copyable.
Definition at line 109 of file run_configuration.cc.