Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
cef6751d
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cef6751d
编写于
10月 10, 2019
作者:
C
Chinmay Garde
提交者:
GitHub
10月 10, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Test child isolates are terminated when root is shutdown (#13048)" (#13067)
This reverts commit
e96c7404
.
上级
e96c7404
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
89 deletion
+24
-89
runtime/dart_isolate_unittests.cc
runtime/dart_isolate_unittests.cc
+24
-74
runtime/fixtures/runtime_test.dart
runtime/fixtures/runtime_test.dart
+0
-15
未找到文件。
runtime/dart_isolate_unittests.cc
浏览文件 @
cef6751d
...
...
@@ -99,27 +99,22 @@ class AutoIsolateShutdown {
AutoIsolateShutdown
()
=
default
;
AutoIsolateShutdown
(
std
::
shared_ptr
<
DartIsolate
>
isolate
,
fml
::
RefPtr
<
fml
::
TaskRunner
>
runner
,
bool
confirm_shutdown
)
:
isolate_
(
std
::
move
(
isolate
)),
runner_
(
std
::
move
(
runner
)),
confirm_shutdown_
(
confirm_shutdown
)
{}
fml
::
RefPtr
<
fml
::
TaskRunner
>
runner
)
:
isolate_
(
std
::
move
(
isolate
)),
runner_
(
std
::
move
(
runner
))
{}
~
AutoIsolateShutdown
()
{
if
(
!
IsValid
())
{
return
;
}
fml
::
AutoResetWaitableEvent
latch
;
fml
::
TaskRunner
::
RunNowOrPostTask
(
runner_
,
[
isolate
=
isolate_
,
&
latch
,
confirm_shutdown
=
confirm_shutdown_
]()
{
FML_LOG
(
INFO
)
<<
"Shutting down isolate."
;
if
(
!
isolate
->
Shutdown
()
&&
confirm_shutdown
)
{
FML_LOG
(
ERROR
)
<<
"Could not shutdown isolate."
;
FML_CHECK
(
false
);
}
latch
.
Signal
();
});
fml
::
TaskRunner
::
RunNowOrPostTask
(
runner_
,
[
isolate
=
isolate_
,
&
latch
]()
{
FML_LOG
(
INFO
)
<<
"Shutting down isolate."
;
if
(
!
isolate
->
Shutdown
())
{
FML_LOG
(
ERROR
)
<<
"Could not shutdown isolate."
;
FML_CHECK
(
false
);
}
latch
.
Signal
();
});
latch
.
Wait
();
}
...
...
@@ -154,7 +149,6 @@ class AutoIsolateShutdown {
private:
std
::
shared_ptr
<
DartIsolate
>
isolate_
;
fml
::
RefPtr
<
fml
::
TaskRunner
>
runner_
;
bool
confirm_shutdown_
;
FML_DISALLOW_COPY_AND_ASSIGN
(
AutoIsolateShutdown
);
};
...
...
@@ -164,8 +158,7 @@ static void RunDartCodeInIsolate(DartVMRef& vm_ref,
const
Settings
&
settings
,
fml
::
RefPtr
<
fml
::
TaskRunner
>
task_runner
,
std
::
string
entrypoint
,
const
std
::
vector
<
std
::
string
>&
args
,
bool
confirm_shutdown
)
{
const
std
::
vector
<
std
::
string
>&
args
)
{
FML_CHECK
(
task_runner
->
RunsTasksOnCurrentThread
());
if
(
!
vm_ref
)
{
...
...
@@ -200,8 +193,8 @@ static void RunDartCodeInIsolate(DartVMRef& vm_ref,
settings
.
isolate_shutdown_callback
// isolate shutdown callback
);
auto
root_isolate
=
std
::
make_unique
<
AutoIsolateShutdown
>
(
weak_isolate
.
lock
(),
task_runner
,
confirm_shutdown
);
auto
root_isolate
=
std
::
make_unique
<
AutoIsolateShutdown
>
(
weak_isolate
.
lock
(),
task_runner
);
if
(
!
root_isolate
->
IsValid
())
{
FML_LOG
(
ERROR
)
<<
"Could not create isolate."
;
...
...
@@ -274,14 +267,13 @@ static std::unique_ptr<AutoIsolateShutdown> RunDartCodeInIsolate(
const
Settings
&
settings
,
fml
::
RefPtr
<
fml
::
TaskRunner
>
task_runner
,
std
::
string
entrypoint
,
const
std
::
vector
<
std
::
string
>&
args
,
bool
confirm_shutdown
)
{
const
std
::
vector
<
std
::
string
>&
args
)
{
std
::
unique_ptr
<
AutoIsolateShutdown
>
result
;
fml
::
AutoResetWaitableEvent
latch
;
fml
::
TaskRunner
::
RunNowOrPostTask
(
task_runner
,
fml
::
MakeCopyable
([
&
]()
mutable
{
RunDartCodeInIsolate
(
vm_ref
,
result
,
settings
,
task_runner
,
entrypoint
,
args
,
confirm_shutdown
);
args
);
latch
.
Signal
();
}));
latch
.
Wait
();
...
...
@@ -293,7 +285,7 @@ TEST_F(DartIsolateTest, IsolateCanLoadAndRunDartCode) {
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
GetCurrentTaskRunner
(),
"main"
,
{}
,
true
);
"main"
,
{});
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
}
...
...
@@ -303,7 +295,7 @@ TEST_F(DartIsolateTest, IsolateCannotLoadAndRunUnknownDartEntrypoint) {
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
GetCurrentTaskRunner
(),
"thisShouldNotExist"
,
{}
,
true
);
"thisShouldNotExist"
,
{});
ASSERT_FALSE
(
isolate
);
}
...
...
@@ -312,7 +304,7 @@ TEST_F(DartIsolateTest, CanRunDartCodeCodeSynchronously) {
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
GetCurrentTaskRunner
(),
"main"
,
{}
,
true
);
"main"
,
{});
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
...
...
@@ -336,7 +328,7 @@ TEST_F(DartIsolateTest, CanRegisterNativeCallback) {
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
CreateNewThread
(),
"canRegisterNativeCallback"
,
{}
,
true
);
"canRegisterNativeCallback"
,
{});
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
latch
.
Wait
();
...
...
@@ -359,7 +351,7 @@ TEST_F(DartIsolateTest, CanSaveCompilationTrace) {
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
CreateNewThread
(),
"testCanSaveCompilationTrace"
,
{}
,
true
);
"testCanSaveCompilationTrace"
,
{});
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
...
...
@@ -385,9 +377,8 @@ TEST_F(DartIsolateTest, CanLaunchSecondaryIsolates) {
child_shutdown_latch
.
Signal
();
};
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
CreateNewThread
(),
"testCanLaunchSecondaryIsolate"
,
{},
true
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
CreateNewThread
(),
"testCanLaunchSecondaryIsolate"
,
{});
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
child_shutdown_latch
.
Wait
();
// wait for child isolate to shutdown first
...
...
@@ -406,54 +397,13 @@ TEST_F(DartIsolateTest, CanRecieveArguments) {
const
auto
settings
=
CreateSettingsForFixture
();
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
CreateNewThread
(),
"testCanRecieveArguments"
,
{
"arg1"
},
true
);
auto
isolate
=
RunDartCodeInIsolate
(
vm_ref
,
settings
,
CreateNewThread
(),
"testCanRecieveArguments"
,
{
"arg1"
});
ASSERT_TRUE
(
isolate
);
ASSERT_EQ
(
isolate
->
get
()
->
GetPhase
(),
DartIsolate
::
Phase
::
Running
);
latch
.
Wait
();
}
TEST_F
(
DartIsolateTest
,
RootIsolateShutdownStopsChildIsolates
)
{
ASSERT_FALSE
(
DartVMRef
::
IsInstanceRunning
());
fml
::
CountDownLatch
latch
(
12
);
fml
::
CountDownLatch
shutdown_latch
(
5
);
AddNativeCallback
(
"NotifyNative"
,
CREATE_NATIVE_ENTRY
(([
&
latch
](
Dart_NativeArguments
args
)
{
latch
.
CountDown
();
})));
AddNativeCallback
(
"PassMessage"
,
CREATE_NATIVE_ENTRY
(([
&
latch
](
Dart_NativeArguments
args
)
{
auto
message
=
tonic
::
DartConverter
<
std
::
string
>::
FromDart
(
Dart_GetNativeArgument
(
args
,
0
));
ASSERT_EQ
(
"In child Isolate."
,
message
);
latch
.
CountDown
();
})));
size_t
destruction_callback_count
=
0
;
auto
settings
=
CreateSettingsForFixture
();
settings
.
isolate_shutdown_callback
=
[
&
shutdown_latch
,
&
destruction_callback_count
]()
{
destruction_callback_count
++
;
shutdown_latch
.
CountDown
();
};
auto
vm_ref
=
DartVMRef
::
Create
(
settings
);
auto
vm_data
=
vm_ref
.
GetVMData
();
std
::
unique_ptr
<
AutoIsolateShutdown
>
isolate
;
fml
::
RefPtr
<
fml
::
TaskRunner
>
task_runner
=
CreateNewThread
();
fml
::
TaskRunner
::
RunNowOrPostTask
(
task_runner
,
fml
::
MakeCopyable
([
&
]()
mutable
{
RunDartCodeInIsolate
(
vm_ref
,
isolate
,
settings
,
task_runner
,
"testSecondaryIsolateShutdown"
,
{},
false
);
}));
latch
.
Wait
();
// wait for last NotifyNative called by main isolate
ASSERT_TRUE
(
isolate
->
get
()
->
Shutdown
()
||
true
);
shutdown_latch
.
Wait
();
// root isolate will be auto-shutdown
ASSERT_EQ
(
destruction_callback_count
,
5u
);
}
}
// namespace testing
}
// namespace flutter
runtime/fixtures/runtime_test.dart
浏览文件 @
cef6751d
...
...
@@ -60,18 +60,3 @@ void testCanLaunchSecondaryIsolate() {
void
testCanRecieveArguments
(
List
<
String
>
args
)
{
notifyResult
(
args
!=
null
&&
args
.
length
==
1
&&
args
[
0
]
==
'arg1'
);
}
@pragma
(
'vm:entry-point'
)
void
testSecondaryIsolateShutdown
(
)
{
final
onExit
=
RawReceivePort
((
_
)
{
notifyNative
();
});
Isolate
.
spawn
(
shutdownIsolateMain
,
'You are isolate number 1'
,
onExit:
onExit
.
sendPort
);
Isolate
.
spawn
(
shutdownIsolateMain
,
'You are isolate number 2'
,
onExit:
onExit
.
sendPort
);
Isolate
.
spawn
(
shutdownIsolateMain
,
'You are isolate number 3'
,
onExit:
onExit
.
sendPort
);
Isolate
.
spawn
(
shutdownIsolateMain
,
'You are isolate number 4'
,
onExit:
onExit
.
sendPort
);
}
void
shutdownIsolateMain
(
String
message
)
{
print
(
'Secondary isolate got message: '
+
message
);
passMessage
(
'In child Isolate.'
);
notifyNative
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录