mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
f6900001eb
Remove dead shared snapshot arguments to Dart_CreateIsolateGroup. 6a65ea9cad4b [vm] Remove shared snapshot and reused instructions features. db8370e36147 [gardening] Fix frontend-server dartdevc windows test. 4601bd7bffea Modified supertype check error message to be more descriptive. 0449905e2de6 [CFE] Add a serialization-and-unserialization step to strong test c8b903c2f94f Update CHANGELOG.md 2a12a13d9684 [Test] Skips emit_aot_size_info_flag_test on crossword. b26127fe01a5 [cfe] Add reachability test skeleton
82 lines
2.4 KiB
C++
82 lines
2.4 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.
|
|
|
|
#ifndef FLUTTER_RUNTIME_DART_VM_LIFECYCLE_H_
|
|
#define FLUTTER_RUNTIME_DART_VM_LIFECYCLE_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/lib/ui/isolate_name_server/isolate_name_server.h"
|
|
#include "flutter/runtime/dart_vm.h"
|
|
#include "flutter/runtime/service_protocol.h"
|
|
|
|
namespace flutter {
|
|
|
|
// A strong reference to the Dart VM. There can only be one VM running in the
|
|
// process at any given time. A reference to the VM may only be obtained via the
|
|
// |Create| method. In case there is already a running instance of the VM in the
|
|
// process, a strong reference to that VM is obtained and the arguments to the
|
|
// |Create| call ignored. If there is no VM already running in the process, a VM
|
|
// is initialized in a thread safe manner and returned to the caller. The VM
|
|
// will shutdown only when all callers relinquish their references (by
|
|
// collecting their instances of this class).
|
|
//
|
|
// DartVMRef instances may be created on any thread.
|
|
class DartVMRef {
|
|
public:
|
|
FML_WARN_UNUSED_RESULT
|
|
static DartVMRef Create(Settings settings,
|
|
fml::RefPtr<DartSnapshot> vm_snapshot = nullptr,
|
|
fml::RefPtr<DartSnapshot> isolate_snapshot = nullptr);
|
|
|
|
DartVMRef(DartVMRef&&);
|
|
|
|
~DartVMRef();
|
|
|
|
// This is an inherently racy way to check if a VM instance is running and
|
|
// should not be used outside of unit-tests where there is a known threading
|
|
// model.
|
|
static bool IsInstanceRunning();
|
|
|
|
static std::shared_ptr<const DartVMData> GetVMData();
|
|
|
|
static std::shared_ptr<ServiceProtocol> GetServiceProtocol();
|
|
|
|
static std::shared_ptr<IsolateNameServer> GetIsolateNameServer();
|
|
|
|
operator bool() const { return static_cast<bool>(vm_); }
|
|
|
|
DartVM* get() {
|
|
FML_DCHECK(vm_);
|
|
return vm_.get();
|
|
}
|
|
|
|
DartVM* operator->() {
|
|
FML_DCHECK(vm_);
|
|
return vm_.get();
|
|
}
|
|
|
|
DartVM* operator&() {
|
|
FML_DCHECK(vm_);
|
|
return vm_.get();
|
|
}
|
|
|
|
private:
|
|
friend class DartIsolate;
|
|
|
|
std::shared_ptr<DartVM> vm_;
|
|
|
|
DartVMRef(std::shared_ptr<DartVM> vm);
|
|
|
|
// Only used by Dart Isolate to register itself with the VM.
|
|
static DartVM* GetRunningVM();
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(DartVMRef);
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_RUNTIME_DART_VM_LIFECYCLE_H_
|