Flutter Engine
dart_isolate_runner.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_TESTING_DART_ISOLATE_RUNNER_H_
6 #define FLUTTER_TESTING_DART_ISOLATE_RUNNER_H_
7 
8 #include "flutter/common/task_runners.h"
9 #include "flutter/fml/make_copyable.h"
10 #include "flutter/fml/paths.h"
11 #include "flutter/fml/synchronization/waitable_event.h"
12 #include "flutter/fml/thread.h"
13 #include "flutter/runtime/dart_isolate.h"
14 #include "flutter/runtime/dart_vm.h"
15 #include "flutter/runtime/dart_vm_lifecycle.h"
16 
17 namespace flutter {
18 namespace testing {
19 
21  public:
22  AutoIsolateShutdown() = default;
23 
24  AutoIsolateShutdown(std::shared_ptr<DartIsolate> isolate,
26 
28 
29  bool IsValid() const { return isolate_ != nullptr && runner_; }
30 
31  [[nodiscard]] bool RunInIsolateScope(std::function<bool(void)> closure);
32 
33  DartIsolate* get() {
34  FML_CHECK(isolate_);
35  return isolate_.get();
36  }
37 
38  private:
39  std::shared_ptr<DartIsolate> isolate_;
41 
42  FML_DISALLOW_COPY_AND_ASSIGN(AutoIsolateShutdown);
43 };
44 
45 void RunDartCodeInIsolate(DartVMRef& vm_ref,
46  std::unique_ptr<AutoIsolateShutdown>& result,
47  const Settings& settings,
48  const TaskRunners& task_runners,
49  std::string entrypoint,
50  const std::vector<std::string>& args,
51  const std::string& fixtures_path,
52  fml::WeakPtr<IOManager> io_manager = {});
53 
54 std::unique_ptr<AutoIsolateShutdown> RunDartCodeInIsolate(
55  DartVMRef& vm_ref,
56  const Settings& settings,
57  const TaskRunners& task_runners,
58  std::string entrypoint,
59  const std::vector<std::string>& args,
60  const std::string& fixtures_path,
61  fml::WeakPtr<IOManager> io_manager = {});
62 
63 } // namespace testing
64 } // namespace flutter
65 
66 #endif // FLUTTER_TESTING_DART_ISOLATE_RUNNER_H_
Dart_NativeFunction function
Definition: fuchsia.cc:51
std::function< void()> closure
Definition: closure.h:14
Represents an instance of a live isolate. An isolate is a separate Dart execution context...
Definition: dart_isolate.h:62
#define FML_CHECK(condition)
Definition: logging.h:68
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)
bool RunInIsolateScope(std::function< bool(void)> closure)