mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This enables work ongoing by @derekxu16 to improve performance in flutter_tester when running multiple files from large test suites. Specifically, it: - Exposes a `Spawn` C symbol from flutter_tester that runs the current kernel in a new UI isolate with a different entrypoint and/or route name - Exposes two symbols from flutter_tester to allow a test harness to more efficiently load particular kernel files or to lookup an entrypoint from an imported source file. - Avoids re-loading the kernel file completely when spawning a new UI isolate Googlers can look at go/flutter-tester-isolates for some more context. If anyone wants I'm happy to create a public version of that doc.
97 lines
3.1 KiB
C++
97 lines
3.1 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/runtime/dart_isolate_group_data.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "flutter/runtime/dart_snapshot.h"
|
|
|
|
namespace flutter {
|
|
|
|
DartIsolateGroupData::DartIsolateGroupData(
|
|
const Settings& settings,
|
|
fml::RefPtr<const DartSnapshot> isolate_snapshot,
|
|
std::string advisory_script_uri,
|
|
std::string advisory_script_entrypoint,
|
|
const ChildIsolatePreparer& child_isolate_preparer,
|
|
const fml::closure& isolate_create_callback,
|
|
const fml::closure& isolate_shutdown_callback)
|
|
: settings_(settings),
|
|
isolate_snapshot_(std::move(isolate_snapshot)),
|
|
advisory_script_uri_(std::move(advisory_script_uri)),
|
|
advisory_script_entrypoint_(std::move(advisory_script_entrypoint)),
|
|
child_isolate_preparer_(child_isolate_preparer),
|
|
isolate_create_callback_(isolate_create_callback),
|
|
isolate_shutdown_callback_(isolate_shutdown_callback) {
|
|
FML_DCHECK(isolate_snapshot_) << "Must contain a valid isolate snapshot.";
|
|
}
|
|
|
|
DartIsolateGroupData::~DartIsolateGroupData() = default;
|
|
|
|
const Settings& DartIsolateGroupData::GetSettings() const {
|
|
return settings_;
|
|
}
|
|
|
|
fml::RefPtr<const DartSnapshot> DartIsolateGroupData::GetIsolateSnapshot()
|
|
const {
|
|
return isolate_snapshot_;
|
|
}
|
|
|
|
const std::string& DartIsolateGroupData::GetAdvisoryScriptURI() const {
|
|
return advisory_script_uri_;
|
|
}
|
|
|
|
const std::string& DartIsolateGroupData::GetAdvisoryScriptEntrypoint() const {
|
|
return advisory_script_entrypoint_;
|
|
}
|
|
|
|
ChildIsolatePreparer DartIsolateGroupData::GetChildIsolatePreparer() const {
|
|
std::scoped_lock lock(child_isolate_preparer_mutex_);
|
|
return child_isolate_preparer_;
|
|
}
|
|
|
|
const fml::closure& DartIsolateGroupData::GetIsolateCreateCallback() const {
|
|
return isolate_create_callback_;
|
|
}
|
|
|
|
const fml::closure& DartIsolateGroupData::GetIsolateShutdownCallback() const {
|
|
return isolate_shutdown_callback_;
|
|
}
|
|
|
|
void DartIsolateGroupData::SetChildIsolatePreparer(
|
|
const ChildIsolatePreparer& value) {
|
|
std::scoped_lock lock(child_isolate_preparer_mutex_);
|
|
child_isolate_preparer_ = value;
|
|
}
|
|
|
|
void DartIsolateGroupData::SetPlatformMessageHandler(
|
|
int64_t root_isolate_token,
|
|
std::weak_ptr<PlatformMessageHandler> handler) {
|
|
std::scoped_lock lock(platform_message_handlers_mutex_);
|
|
platform_message_handlers_[root_isolate_token] = handler;
|
|
}
|
|
|
|
std::weak_ptr<PlatformMessageHandler>
|
|
DartIsolateGroupData::GetPlatformMessageHandler(
|
|
int64_t root_isolate_token) const {
|
|
std::scoped_lock lock(platform_message_handlers_mutex_);
|
|
auto it = platform_message_handlers_.find(root_isolate_token);
|
|
return it == platform_message_handlers_.end()
|
|
? std::weak_ptr<PlatformMessageHandler>()
|
|
: it->second;
|
|
}
|
|
|
|
void DartIsolateGroupData::AddKernelBuffer(
|
|
const std::shared_ptr<const fml::Mapping>& buffer) {
|
|
kernel_buffers_.push_back(buffer);
|
|
}
|
|
|
|
std::vector<std::shared_ptr<const fml::Mapping>>
|
|
DartIsolateGroupData::GetKernelBuffers() const {
|
|
return kernel_buffers_;
|
|
}
|
|
|
|
} // namespace flutter
|