Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8d8af6d0
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8d8af6d0
编写于
5月 23, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8609 add priority task xts
Merge pull request !8609 from buzhuyu/master
上级
3cb14486
ce180e57
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
24 deletion
+61
-24
commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
...ool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
+61
-24
未找到文件。
commonlibrary/ets_utils/taskpool_lib_standard/entry/src/main/ets/test/TaskPool.test.js
浏览文件 @
8d8af6d0
...
...
@@ -357,7 +357,7 @@ describe('ActsAbilityTest', function () {
while
(
!
isTerminate
)
{
await
promiseCase
()
}
expect
(
result
).
assertEqual
(
30
);
expect
(
result
).
assertEqual
(
30
);
done
();
})
...
...
@@ -522,7 +522,7 @@ describe('ActsAbilityTest', function () {
result1
=
ret1
;
isTerminate1
=
true
;
})
var
task2
=
new
taskpool
.
Task
(
Sum
,
30
,
40
);
taskpool
.
execute
(
task2
).
then
((
ret2
)
=>
{
result2
=
ret2
;
...
...
@@ -789,7 +789,7 @@ describe('ActsAbilityTest', function () {
var
isTerminate
=
false
;
taskpool
.
execute
(
Sum
,
10
,
20
,
30
).
then
((
ret
)
=>
{
result
=
ret
;
isTerminate
=
true
;
isTerminate
=
true
;
})
while
(
!
isTerminate
)
{
await
promiseCase
()
...
...
@@ -810,11 +810,11 @@ describe('ActsAbilityTest', function () {
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret1
)
=>
{
result1
=
ret1
;
isTerminate1
=
true
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
Sum
,
30
,
40
).
then
((
ret2
)
=>
{
result2
=
ret2
;
isTerminate2
=
true
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
...
...
@@ -836,11 +836,11 @@ describe('ActsAbilityTest', function () {
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret1
)
=>
{
result1
=
ret1
;
isTerminate1
=
true
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret2
)
=>
{
result2
=
ret2
;
isTerminate2
=
true
;
isTerminate2
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
)
{
await
promiseCase
()
...
...
@@ -871,19 +871,19 @@ describe('ActsAbilityTest', function () {
taskpool
.
execute
(
Sum
,
10
,
20
).
then
((
ret1
)
=>
{
result1
=
ret1
;
isTerminate1
=
true
;
isTerminate1
=
true
;
})
taskpool
.
execute
(
Multi
,
10
,
20
).
then
((
ret2
)
=>
{
result2
=
ret2
;
isTerminate2
=
true
;
isTerminate2
=
true
;
})
taskpool
.
execute
(
Sum
,
10
,
30
).
then
((
ret3
)
=>
{
result3
=
ret3
;
isTerminate3
=
true
;
isTerminate3
=
true
;
})
taskpool
.
execute
(
Multi
,
20
,
20
).
then
((
ret4
)
=>
{
result4
=
ret4
;
isTerminate4
=
true
;
isTerminate4
=
true
;
})
while
(
!
isTerminate1
||
!
isTerminate2
||
!
isTerminate3
||
!
isTerminate4
)
{
await
promiseCase
()
...
...
@@ -908,20 +908,57 @@ describe('ActsAbilityTest', function () {
done
();
})
/**
* @tc.number : TaskPoolTestClass061
* @tc.name : Async Function about priority task
* @tc.desc : Execute priority tasks
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
TaskPoolTestClass061
'
,
0
,
async
function
(
done
)
{
function
Sum
(
value1
,
value2
)
{
"
use concurrent
"
return
value1
+
value2
;
function
testTime
()
{
"
use concurrent
"
;
return
Date
.
now
();
}
let
task
=
new
taskpool
.
Task
(
testTime
);
let
isEnd
=
false
;
let
begin
=
Date
.
now
();
let
highTime
=
0
;
let
mediumTime
=
0
;
let
lowTime
=
0
;
let
lowCount
=
0
;
let
allCount
=
100
;
for
(
let
i
=
0
;
i
<
allCount
;
i
++
)
{
taskpool
.
execute
(
task
,
taskpool
.
Priority
.
LOW
).
then
((
res
)
=>
{
lowCount
++
;
lowTime
+=
(
res
-
begin
);
if
(
lowCount
==
allCount
)
{
isEnd
=
true
;
}
}).
catch
((
e
)
=>
{
console
.
error
(
"
all low find error:
"
+
e
)
})
taskpool
.
execute
(
task
,
taskpool
.
Priority
.
MEDIUM
).
then
((
res
)
=>
{
mediumTime
+=
(
res
-
begin
);
}).
catch
((
e
)
=>
{
console
.
error
(
"
all medium find error:
"
+
e
)
})
taskpool
.
execute
(
task
,
taskpool
.
Priority
.
HIGH
).
then
((
res
)
=>
{
highTime
+=
(
res
-
begin
);
}).
catch
((
e
)
=>
{
console
.
error
(
"
all high find error:
"
+
e
)
})
}
var
task1
=
new
taskpool
.
Task
(
Sum
,
10
,
20
);
var
task2
=
new
taskpool
.
Task
(
Sum
,
30
,
40
);
var
task3
=
new
taskpool
.
Task
(
Sum
,
50
,
60
);
var
result1
=
await
taskpool
.
execute
(
task1
,
taskpool
.
Priority
.
LOW
);
var
result2
=
await
taskpool
.
execute
(
task2
,
taskpool
.
Priority
.
HIGH
);
var
result3
=
await
taskpool
.
execute
(
task3
,
taskpool
.
Priority
.
MEDIUM
);
expect
(
result1
).
assertEqual
(
30
);
expect
(
result2
).
assertEqual
(
70
);
expect
(
result3
).
assertEqual
(
110
);
while
(
!
isEnd
)
{
await
promiseCase
()
}
expect
(
lowTime
>
mediumTime
&&
mediumTime
>
highTime
);
done
();
})
...
...
@@ -938,7 +975,7 @@ describe('ActsAbilityTest', function () {
expect
(
result
).
assertEqual
(
30
);
done
();
})
it
(
'
TaskPoolTestClass063
'
,
0
,
async
function
(
done
)
{
async
function
func
(
value1
,
value2
)
{
"
use concurrent
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录