Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
platform_isolate_manager.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_RUNTIME_PLATFORM_ISOLATE_MANAGER_H_
6#define FLUTTER_RUNTIME_PLATFORM_ISOLATE_MANAGER_H_
7
8#include <atomic>
9#include <mutex>
10#include <unordered_set>
11
12#include "third_party/dart/runtime/include/dart_api.h"
13
14namespace flutter {
15
16/// Maintains a list of registered platform isolates, so that they can be
17/// proactively shutdown as a group during shell shutdown.
19 public:
20 /// Returns whether the PlatformIsolateManager is shutdown. New isolates
21 /// cannot be registered after the manager is shutdown. Must be called on the
22 /// platform thread.
23 bool HasShutdown();
24
25 /// Returns whether the PlatformIsolateManager is shutdown. New isolates
26 /// cannot be registered after the manager is shutdown. Callable from any
27 /// thread. The result may be obsolete immediately after the call.
29
30 /// Register an isolate in the list of platform isolates. Callable from any
31 /// thread.
33
34 /// Remove an isolate from the list of platform isolates. Must be called from
35 /// the platform thread.
37
38 /// Shuts down all registered isolates, and the manager itself. Must be called
39 /// from the platform thread.
41
42 /// Returns whether an isolate is registered. For testing only. Callable from
43 /// any thread.
45
46 private:
47 // This lock must be recursive because ShutdownPlatformIsolates indirectly
48 // calls RemovePlatformIsolate.
49 std::recursive_mutex lock_;
50 std::unordered_set<Dart_Isolate> platform_isolates_;
51 bool is_shutdown_ = false;
52};
53
54} // namespace flutter
55
56#endif // FLUTTER_RUNTIME_PLATFORM_ISOLATE_MANAGER_H_
void RemovePlatformIsolate(Dart_Isolate isolate)
bool IsRegisteredForTestingOnly(Dart_Isolate isolate)
bool RegisterPlatformIsolate(Dart_Isolate isolate)
struct _Dart_Isolate * Dart_Isolate
Definition dart_api.h:88