Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
platform_isolate_manager.cc
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#include "flutter/runtime/platform_isolate_manager.h"
6
7#include "flutter/runtime/dart_isolate.h"
8
9namespace flutter {
10
12 // TODO(flutter/flutter#136314): Assert that we're on the platform thread.
13 std::scoped_lock lock(lock_);
14 return is_shutdown_;
15}
16
18 std::scoped_lock lock(lock_);
19 return is_shutdown_;
20}
21
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}
32
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}
50
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}
64
66 std::scoped_lock lock(lock_);
67 return platform_isolates_.find(isolate) != platform_isolates_.end();
68}
69
70} // namespace flutter
void RemovePlatformIsolate(Dart_Isolate isolate)
bool IsRegisteredForTestingOnly(Dart_Isolate isolate)
bool RegisterPlatformIsolate(Dart_Isolate isolate)
DART_EXPORT void Dart_ShutdownIsolate(void)
struct _Dart_Isolate * Dart_Isolate
Definition dart_api.h:88
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
#define FML_DCHECK(condition)
Definition logging.h:103