提交 36e9f30d 编写于 作者: W wangzhaoyong

add "use concurrent"

Signed-off-by: Nwangzhaoyong <wangzhaoyong@huawei.com>
Change-Id: I6542a2b3f50d676f6643023e9f3d7132bfdc26b4
上级 628648be
...@@ -58,6 +58,7 @@ Task构造函数 ...@@ -58,6 +58,7 @@ Task构造函数
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';
function func(args) { function func(args) {
"use concurrent"
console.log("func: " + args); console.log("func: " + args);
return args; return args;
} }
...@@ -98,12 +99,12 @@ execute(func: Function, ...args: unknown[]): Promise<unknown> ...@@ -98,12 +99,12 @@ execute(func: Function, ...args: unknown[]): Promise<unknown>
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';
function func(args) { function func(args) {
"use concurrent"
console.log("func: " + args); console.log("func: " + args);
return args; return args;
} }
async function asyncCall() {
let value = await taskpool.execute(func, 100); let value = taskpool.execute(func, 100);
}
``` ```
...@@ -138,13 +139,12 @@ execute(task: Task, priority?: Priority): Promise<unknown>; ...@@ -138,13 +139,12 @@ execute(task: Task, priority?: Priority): Promise<unknown>;
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';
function func(args) { function func(args) {
"use concurrent"
console.log("func: " + args); console.log("func: " + args);
return args; return args;
} }
var task = new taskpool.Task(func, "this is first Task"); var task = new taskpool.Task(func, "this is first Task");
async function asyncCall() { let value = taskpool.execute(task);
let value = await taskpool.execute(task);
}
``` ```
...@@ -180,6 +180,7 @@ cancel(task: Task): void ...@@ -180,6 +180,7 @@ cancel(task: Task): void
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';
function func(args) { function func(args) {
"use concurrent"
console.log("func: " + args); console.log("func: " + args);
return args; return args;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册