forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dart_isolate_runner.h
71 lines (55 loc) · 2.06 KB
/
dart_isolate_runner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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_TESTING_DART_ISOLATE_RUNNER_H_
#define FLUTTER_TESTING_DART_ISOLATE_RUNNER_H_
#include "flutter/common/task_runners.h"
#include "flutter/fml/make_copyable.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/thread.h"
#include "flutter/runtime/dart_isolate.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/runtime/dart_vm_lifecycle.h"
namespace flutter {
namespace testing {
class AutoIsolateShutdown {
public:
AutoIsolateShutdown() = default;
AutoIsolateShutdown(std::shared_ptr<DartIsolate> isolate,
fml::RefPtr<fml::TaskRunner> runner);
~AutoIsolateShutdown();
bool IsValid() const { return isolate_ != nullptr && runner_; }
[[nodiscard]] bool RunInIsolateScope(std::function<bool(void)> closure);
void Shutdown();
DartIsolate* get() {
FML_CHECK(isolate_);
return isolate_.get();
}
private:
std::shared_ptr<DartIsolate> isolate_;
fml::RefPtr<fml::TaskRunner> runner_;
FML_DISALLOW_COPY_AND_ASSIGN(AutoIsolateShutdown);
};
void RunDartCodeInIsolate(
DartVMRef& vm_ref,
std::unique_ptr<AutoIsolateShutdown>& result,
const Settings& settings,
const TaskRunners& task_runners,
std::string entrypoint,
const std::vector<std::string>& args,
const std::string& fixtures_path,
fml::WeakPtr<IOManager> io_manager = {},
std::shared_ptr<VolatilePathTracker> volatile_path_tracker = nullptr);
std::unique_ptr<AutoIsolateShutdown> RunDartCodeInIsolate(
DartVMRef& vm_ref,
const Settings& settings,
const TaskRunners& task_runners,
std::string entrypoint,
const std::vector<std::string>& args,
const std::string& fixtures_path,
fml::WeakPtr<IOManager> io_manager = {},
std::shared_ptr<VolatilePathTracker> volatile_path_tracker = nullptr);
} // namespace testing
} // namespace flutter
#endif // FLUTTER_TESTING_DART_ISOLATE_RUNNER_H_