Flutter Engine
The Flutter Engine
lib
ui
window
platform_isolate.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 <iostream>
6
#include <thread>
7
8
#include "flutter/fml/macros.h"
9
#include "flutter/fml/task_runner.h"
10
#include "flutter/lib/ui/ui_dart_state.h"
11
#include "flutter/lib/ui/window/platform_isolate.h"
12
#include "
third_party/tonic/converter/dart_converter.h
"
13
14
namespace
flutter
{
15
16
void
PlatformIsolateNativeApi::Spawn
(
Dart_Handle
entry_point) {
17
UIDartState
* current_state =
UIDartState::Current
();
18
FML_DCHECK
(current_state !=
nullptr
);
19
if
(!current_state->
IsRootIsolate
()) {
20
// TODO(flutter/flutter#136314): Remove this restriction.
21
Dart_EnterScope
();
22
Dart_ThrowException
(
tonic::ToDart
(
23
"PlatformIsolates can only be spawned on the root isolate."
));
24
}
25
26
char
*
error
=
nullptr
;
27
current_state->
CreatePlatformIsolate
(entry_point, &
error
);
28
if
(
error
) {
29
Dart_EnterScope
();
30
Dart_Handle
error_handle = tonic::ToDart<const char*>(
error
);
31
::free(
error
);
32
Dart_ThrowException
(error_handle);
33
}
34
}
35
36
bool
PlatformIsolateNativeApi::IsRunningOnPlatformThread
() {
37
UIDartState
* current_state =
UIDartState::Current
();
38
FML_DCHECK
(current_state !=
nullptr
);
39
fml::RefPtr<fml::TaskRunner>
platform_task_runner =
40
current_state->
GetTaskRunners
().
GetPlatformTaskRunner
();
41
if
(!platform_task_runner) {
42
return
false
;
43
}
44
return
platform_task_runner->
RunsTasksOnCurrentThread
();
45
}
46
47
}
// namespace flutter
flutter::PlatformIsolateNativeApi::IsRunningOnPlatformThread
static bool IsRunningOnPlatformThread()
Definition:
platform_isolate.cc:36
flutter::PlatformIsolateNativeApi::Spawn
static void Spawn(Dart_Handle entry_point)
Definition:
platform_isolate.cc:16
flutter::TaskRunners::GetPlatformTaskRunner
fml::RefPtr< fml::TaskRunner > GetPlatformTaskRunner() const
Definition:
task_runners.cc:30
flutter::UIDartState
Definition:
ui_dart_state.h:36
flutter::UIDartState::IsRootIsolate
bool IsRootIsolate() const
Definition:
ui_dart_state.h:111
flutter::UIDartState::GetTaskRunners
const TaskRunners & GetTaskRunners() const
Definition:
ui_dart_state.cc:139
flutter::UIDartState::CreatePlatformIsolate
virtual Dart_Isolate CreatePlatformIsolate(Dart_Handle entry_point, char **error)
Definition:
ui_dart_state.cc:265
flutter::UIDartState::Current
static UIDartState * Current()
Definition:
ui_dart_state.cc:119
fml::RefPtr< fml::TaskRunner >
fml::TaskRunner::RunsTasksOnCurrentThread
virtual bool RunsTasksOnCurrentThread()
Definition:
task_runner.cc:43
Dart_EnterScope
DART_EXPORT void Dart_EnterScope(void)
Dart_Handle
struct _Dart_Handle * Dart_Handle
Definition:
dart_api.h:258
Dart_ThrowException
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
dart_converter.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition:
fl_pixel_buffer_texture_test.cc:40
FML_DCHECK
#define FML_DCHECK(condition)
Definition:
logging.h:103
flutter
Definition:
asset_manager.cc:10
tonic::ToDart
Dart_Handle ToDart(const T &object)
Definition:
dart_converter.h:579
Generated on Sun Jun 23 2024 21:55:06 for Flutter Engine by
1.9.4