Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::PlatformIsolateManager Class Reference

#include <platform_isolate_manager.h>

Public Member Functions

bool HasShutdown ()
 
bool HasShutdownMaybeFalseNegative ()
 
bool RegisterPlatformIsolate (Dart_Isolate isolate)
 
void RemovePlatformIsolate (Dart_Isolate isolate)
 
void ShutdownPlatformIsolates ()
 
bool IsRegisteredForTestingOnly (Dart_Isolate isolate)
 

Detailed Description

Maintains a list of registered platform isolates, so that they can be proactively shutdown as a group during shell shutdown.

Definition at line 18 of file platform_isolate_manager.h.

Member Function Documentation

◆ HasShutdown()

bool flutter::PlatformIsolateManager::HasShutdown ( )

Returns whether the PlatformIsolateManager is shutdown. New isolates cannot be registered after the manager is shutdown. Must be called on the platform thread.

Definition at line 11 of file platform_isolate_manager.cc.

11 {
12 // TODO(flutter/flutter#136314): Assert that we're on the platform thread.
13 std::scoped_lock lock(lock_);
14 return is_shutdown_;
15}

◆ HasShutdownMaybeFalseNegative()

bool flutter::PlatformIsolateManager::HasShutdownMaybeFalseNegative ( )

Returns whether the PlatformIsolateManager is shutdown. New isolates cannot be registered after the manager is shutdown. Callable from any thread. The result may be obsolete immediately after the call.

Definition at line 17 of file platform_isolate_manager.cc.

17 {
18 std::scoped_lock lock(lock_);
19 return is_shutdown_;
20}

◆ IsRegisteredForTestingOnly()

bool flutter::PlatformIsolateManager::IsRegisteredForTestingOnly ( Dart_Isolate  isolate)

Returns whether an isolate is registered. For testing only. Callable from any thread.

Definition at line 65 of file platform_isolate_manager.cc.

65 {
66 std::scoped_lock lock(lock_);
67 return platform_isolates_.find(isolate) != platform_isolates_.end();
68}

◆ RegisterPlatformIsolate()

bool flutter::PlatformIsolateManager::RegisterPlatformIsolate ( Dart_Isolate  isolate)

Register an isolate in the list of platform isolates. Callable from any thread.

Definition at line 22 of file platform_isolate_manager.cc.

22 {
23 std::scoped_lock lock(lock_);
24 if (is_shutdown_) {
25 // It's possible shutdown occured while we were trying to aquire the lock.
26 return false;
27 }
28 FML_DCHECK(platform_isolates_.find(isolate) == platform_isolates_.end());
29 platform_isolates_.insert(isolate);
30 return true;
31}
#define FML_DCHECK(condition)
Definition logging.h:103

◆ RemovePlatformIsolate()

void flutter::PlatformIsolateManager::RemovePlatformIsolate ( Dart_Isolate  isolate)

Remove an isolate from the list of platform isolates. Must be called from the platform thread.

Definition at line 33 of file platform_isolate_manager.cc.

33 {
34 // This method is only called by DartIsolate::OnShutdownCallback() during
35 // isolate shutdown. This can happen either during the ordinary platform
36 // isolate shutdown, or during ShutdownPlatformIsolates(). In either case
37 // we're on the platform thread.
38 // TODO(flutter/flutter#136314): Assert that we're on the platform thread.
39 // Need a method that works for ShutdownPlatformIsolates() too.
40 std::scoped_lock lock(lock_);
41 if (is_shutdown_) {
42 // Removal during ShutdownPlatformIsolates. Ignore, to avoid modifying
43 // platform_isolates_ during iteration.
44 FML_DCHECK(platform_isolates_.empty());
45 return;
46 }
47 FML_DCHECK(platform_isolates_.find(isolate) != platform_isolates_.end());
48 platform_isolates_.erase(isolate);
49}

◆ ShutdownPlatformIsolates()

void flutter::PlatformIsolateManager::ShutdownPlatformIsolates ( )

Shuts down all registered isolates, and the manager itself. Must be called from the platform thread.

Definition at line 51 of file platform_isolate_manager.cc.

51 {
52 // TODO(flutter/flutter#136314): Assert that we're on the platform thread.
53 // There's no current UIDartState here, so platform_isolate.cc's method won't
54 // work.
55 std::scoped_lock lock(lock_);
56 is_shutdown_ = true;
57 std::unordered_set<Dart_Isolate> platform_isolates;
58 std::swap(platform_isolates_, platform_isolates);
59 for (Dart_Isolate isolate : platform_isolates) {
60 Dart_EnterIsolate(isolate);
62 }
63}
DART_EXPORT void Dart_ShutdownIsolate(void)
struct _Dart_Isolate * Dart_Isolate
Definition dart_api.h:88
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)

The documentation for this class was generated from the following files: