Flutter Engine
The 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
17namespace flutter {
18namespace testing {
19
21 public:
23
24 AutoIsolateShutdown(std::shared_ptr<DartIsolate> isolate,
26
28
29 bool IsValid() const { return isolate_ != nullptr && runner_; }
30
31 [[nodiscard]] bool RunInIsolateScope(
32 const std::function<bool(void)>& closure);
33
34 void Shutdown();
35
37 FML_CHECK(isolate_);
38 return isolate_.get();
39 }
40
41 private:
42 std::shared_ptr<DartIsolate> isolate_;
44
45 FML_DISALLOW_COPY_AND_ASSIGN(AutoIsolateShutdown);
46};
47
49 DartVMRef& vm_ref,
50 std::unique_ptr<AutoIsolateShutdown>& result,
51 const Settings& settings,
52 const TaskRunners& task_runners,
53 std::string entrypoint,
54 const std::vector<std::string>& args,
55 const std::string& fixtures_path,
56 fml::WeakPtr<IOManager> io_manager = {},
57 std::shared_ptr<VolatilePathTracker> volatile_path_tracker = nullptr,
58 std::unique_ptr<PlatformConfiguration> platform_configuration = nullptr);
59
60std::unique_ptr<AutoIsolateShutdown> RunDartCodeInIsolate(
61 DartVMRef& vm_ref,
62 const Settings& settings,
63 const TaskRunners& task_runners,
64 std::string entrypoint,
65 const std::vector<std::string>& args,
66 const std::string& fixtures_path,
67 fml::WeakPtr<IOManager> io_manager = {},
68 std::shared_ptr<VolatilePathTracker> volatile_path_tracker = nullptr,
69 std::unique_ptr<PlatformConfiguration> platform_configuration = nullptr);
70
71} // namespace testing
72} // namespace flutter
73
74#endif // FLUTTER_TESTING_DART_ISOLATE_RUNNER_H_
Represents an instance of a live isolate. An isolate is a separate Dart execution context....
Definition: dart_isolate.h:63
bool RunInIsolateScope(const std::function< bool(void)> &closure)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
GAsyncResult * result
#define FML_CHECK(condition)
Definition: logging.h:85
Dart_NativeFunction function
Definition: fuchsia.cc:51
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 &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::shared_ptr< VolatilePathTracker > volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)
std::function< void()> closure
Definition: closure.h:14