Flutter Engine
 
Loading...
Searching...
No Matches
isolate_scope.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
6#include "third_party/dart/runtime/include/dart_api.h"
7
8#ifndef FLUTTER_SHELL_PLATFORM_COMMON_ISOLATE_SCOPE_H_
9#define FLUTTER_SHELL_PLATFORM_COMMON_ISOLATE_SCOPE_H_
10
11namespace flutter {
12
13/// This class is a thin wrapper around dart isolate. It can be used
14/// as argument to IsolateScope constructor to enter and exit the isolate.
15class Isolate {
16 public:
17 /// Retrieve the current Dart Isolate. If no isolate is current, this
18 /// results in a crash.
19 static Isolate Current();
20
21 ~Isolate() = default;
22
23 private:
24 explicit Isolate(Dart_Isolate isolate) : isolate_(isolate) {
25 FML_DCHECK(isolate_ != nullptr);
26 }
27
28 friend class IsolateScope;
29 Dart_Isolate isolate_;
30};
31
32// Enters provided isolate for as long as the scope is alive.
34 public:
35 explicit IsolateScope(const Isolate& isolate);
37
38 private:
39 Dart_Isolate isolate_;
40 Dart_Isolate previous_;
41
43};
44
45} // namespace flutter
46
47#endif // FLUTTER_SHELL_PLATFORM_COMMON_ISOLATE_SCOPE_H_
static Isolate Current()
~Isolate()=default
#define FML_DCHECK(condition)
Definition logging.h:122
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27