5#include "flutter/runtime/dart_vm_lifecycle.h"
16static std::weak_ptr<DartVM>
gVM;
25static std::weak_ptr<const DartVMData>
gVMData;
31DartVMRef::DartVMRef(DartVMRef&& other) =
default;
33DartVMRef::~DartVMRef() {
41 std::scoped_lock lifecycle_lock(
gVMMutex);
48 std::scoped_lock lifecycle_lock(
gVMMutex);
52 <<
"Launch settings indicated that the VM should shut down in the "
53 "process when done but a previous launch asked the VM to leak in "
54 "the same process. For proper VM shutdown, all VM launches must "
55 "indicate that they should shut down when done.";
60 if (
auto vm =
gVM.lock()) {
61 FML_DLOG(WARNING) <<
"Attempted to create a VM in a process where one was "
62 "already running. Ignoring arguments for current VM "
63 "create call and reusing the old VM.";
77 auto isolate_name_server = std::make_shared<IsolateNameServer>();
79 std::move(vm_snapshot),
80 std::move(isolate_snapshot),
95 gVMLeak =
new std::shared_ptr<DartVM>(vm);
101bool DartVMRef::IsInstanceRunning() {
103 return !
gVM.expired();
106std::shared_ptr<const DartVMData> DartVMRef::GetVMData() {
111std::shared_ptr<ServiceProtocol> DartVMRef::GetServiceProtocol() {
116std::shared_ptr<IsolateNameServer> DartVMRef::GetIsolateNameServer() {
121DartVM* DartVMRef::GetRunningVM() {
123 auto vm =
gVM.lock().get();
124 FML_CHECK(vm) <<
"Caller assumed VM would be running when it wasn't";
static sk_sp< Effect > Create()
DartVMRef(const DartVMRef &)=default
Describes a running instance of the Dart VM. There may only be one running instance of the Dart VM in...
#define FML_DLOG(severity)
#define FML_LOG(severity)
#define FML_CHECK(condition)
static std::weak_ptr< IsolateNameServer > gVMIsolateNameServer
static std::weak_ptr< ServiceProtocol > gVMServiceProtocol
static std::mutex gVMMutex
static std::mutex gVMDependentsMutex
static std::weak_ptr< DartVM > gVM
static std::weak_ptr< const DartVMData > gVMData
static std::shared_ptr< DartVM > * gVMLeak