• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkTS
19 */
20
21/**
22 * JS cross-thread task executor.
23 *
24 * @namespace taskpool
25 * @syscap SystemCapability.Utils.Lang
26 * @since 9
27 */
28/**
29 * JS cross-thread task executor.
30 *
31 * @namespace taskpool
32 * @syscap SystemCapability.Utils.Lang
33 * @crossplatform
34 * @since 10
35 */
36/**
37 * JS cross-thread task executor.
38 *
39 * @namespace taskpool
40 * @syscap SystemCapability.Utils.Lang
41 * @crossplatform
42 * @atomicservice
43 * @since 11
44 */
45declare namespace taskpool {
46  /**
47   * The Priority defines the task priority.
48   *
49   * @enum { number } Priority
50   * @syscap SystemCapability.Utils.Lang
51   * @since 9
52   */
53  /**
54   * The Priority defines the task priority.
55   *
56   * @enum { number } Priority
57   * @syscap SystemCapability.Utils.Lang
58   * @crossplatform
59   * @since 10
60   */
61  /**
62   * The Priority defines the task priority.
63   *
64   * @enum { number } Priority
65   * @syscap SystemCapability.Utils.Lang
66   * @crossplatform
67   * @atomicservice
68   * @since 11
69   */
70  enum Priority {
71    /**
72     * set task priority to high.
73     *
74     * @syscap SystemCapability.Utils.Lang
75     * @since 9
76     */
77    /**
78     * set task priority to high.
79     *
80     * @syscap SystemCapability.Utils.Lang
81     * @crossplatform
82     * @since 10
83     */
84    /**
85     * set task priority to high.
86     *
87     * @syscap SystemCapability.Utils.Lang
88     * @crossplatform
89     * @atomicservice
90     * @since 11
91     */
92    HIGH = 0,
93
94    /**
95     * set task priority to medium.
96     *
97     * @syscap SystemCapability.Utils.Lang
98     * @since 9
99     */
100    /**
101     * set task priority to medium.
102     *
103     * @syscap SystemCapability.Utils.Lang
104     * @crossplatform
105     * @since 10
106     */
107    /**
108     * set task priority to medium.
109     *
110     * @syscap SystemCapability.Utils.Lang
111     * @crossplatform
112     * @atomicservice
113     * @since 11
114     */
115    MEDIUM = 1,
116
117    /**
118     * set task priority to low.
119     *
120     * @syscap SystemCapability.Utils.Lang
121     * @since 9
122     */
123    /**
124     * set task priority to low.
125     *
126     * @syscap SystemCapability.Utils.Lang
127     * @crossplatform
128     * @since 10
129     */
130    /**
131     * set task priority to low.
132     *
133     * @syscap SystemCapability.Utils.Lang
134     * @crossplatform
135     * @atomicservice
136     * @since 11
137     */
138    LOW = 2
139  }
140
141  /**
142   * The Task class provides an interface to create a task.
143   *
144   * @syscap SystemCapability.Utils.Lang
145   * @since 9
146   */
147  /**
148   * The Task class provides an interface to create a task.
149   *
150   * @syscap SystemCapability.Utils.Lang
151   * @crossplatform
152   * @since 10
153   */
154  /**
155   * The Task class provides an interface to create a task.
156   *
157   * @syscap SystemCapability.Utils.Lang
158   * @crossplatform
159   * @atomicservice
160   * @since 11
161   */
162  class Task {
163    /**
164     * Create a Task instance.
165     *
166     * @param { Function } func - func func Concurrent function to execute in taskpool.
167     * @param { unknown[] } args - args args The concurrent function arguments.
168     * @throws { BusinessError } 401 - The input parameters are invalid.
169     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
170     * @syscap SystemCapability.Utils.Lang
171     * @since 9
172     */
173    /**
174     * Create a Task instance.
175     *
176     * @param { Function } func - func func Concurrent function to execute in taskpool.
177     * @param { unknown[] } args - args args The concurrent function arguments.
178     * @throws { BusinessError } 401 - The input parameters are invalid.
179     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
180     * @syscap SystemCapability.Utils.Lang
181     * @crossplatform
182     * @since 10
183     */
184    /**
185     * Create a Task instance.
186     *
187     * @param { Function } func - func func Concurrent function to execute in taskpool.
188     * @param { Object[] } args - args args The concurrent function arguments.
189     * @throws { BusinessError } 401 - The input parameters are invalid.
190     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
191     * @syscap SystemCapability.Utils.Lang
192     * @crossplatform
193     * @atomicservice
194     * @since 11
195     */
196    constructor(func: Function, ...args: Object[]);
197
198    /**
199     * Create a Task instance.
200     *
201     * @param { string } name - name name The name of Task.
202     * @param { Function } func - func func Concurrent function to execute in taskpool.
203     * @param { Object[] } args - args args The concurrent function arguments.
204     * @throws { BusinessError } 401 - The input parameters are invalid.
205     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
206     * @syscap SystemCapability.Utils.Lang
207     * @crossplatform
208     * @atomicservice
209     * @since 11
210     */
211    constructor(name: string, func: Function, ...args: Object[]);
212
213    /**
214     * Check current running Task is canceled or not.
215     *
216     * @returns { boolean } Returns {@code true} if current running task is canceled; returns {@code false} otherwise.
217     * @static
218     * @syscap SystemCapability.Utils.Lang
219     * @crossplatform
220     * @since 10
221     */
222    /**
223     * Check current running Task is canceled or not.
224     *
225     * @returns { boolean } Returns {@code true} if current running task is canceled; returns {@code false} otherwise.
226     * @static
227     * @syscap SystemCapability.Utils.Lang
228     * @crossplatform
229     * @atomicservice
230     * @since 11
231     */
232    static isCanceled(): boolean;
233
234    /**
235     * Send data back to the host side and trigger the registered callback
236     *
237     * @param { Object[] } args - Data to be used as the input parameter of the registered callback.
238     * @throws { BusinessError } 401 - The input parameters are invalid.
239     * @throws { BusinessError } 10200006 - An exception occurred during serialization.
240     * @throws { BusinessError } 10200022 - The function is not called in the taskpool thread.
241     * @throws { BusinessError } 10200023 - The function is not called in the concurrent function.
242     * @throws { BusinessError } 10200024 - The callback is not registered on the host side.
243     * @static
244     * @syscap SystemCapability.Utils.Lang
245     * @crossplatform
246     * @atomicservice
247     * @since 11
248     */
249    static sendData(...args: Object[]): void;
250
251    /**
252     * Set transfer list for this task.
253     *
254     * @param { ArrayBuffer[] } [transfer] - transfer Transfer list of this task, empty array is default.
255     * @throws { BusinessError } 401 - The input parameters are invalid.
256     * @syscap SystemCapability.Utils.Lang
257     * @crossplatform
258     * @since 10
259     */
260    /**
261     * Set transfer list for this task.
262     *
263     * @param { ArrayBuffer[] } [transfer] - transfer Transfer list of this task, empty array is default.
264     * @throws { BusinessError } 401 - The input parameters are invalid.
265     * @throws { BusinessError } 10200029 - Can not set an arraybuffer to both transferList and cloneList.
266     * @syscap SystemCapability.Utils.Lang
267     * @crossplatform
268     * @atomicservice
269     * @since 11
270     */
271    setTransferList(transfer?: ArrayBuffer[]): void;
272
273    /**
274     * Set clone list for this task.
275     *
276     * @param { Object[] | ArrayBuffer[] } cloneList - Sendable objects or arrayBuffer objects in this list
277     * will be transmitted to worker thread in a copy way.
278     * @throws { BusinessError } 401 - The input parameters are invalid.
279     * @throws { BusinessError } 10200029 - Can not set an arraybuffer to both transferList and cloneList.
280     * @syscap SystemCapability.Utils.Lang
281     * @crossplatform
282     * @atomicservice
283     * @since 11
284     */
285    setCloneList(cloneList: Object[] | ArrayBuffer[]): void;
286
287    /**
288     * Register a callback for this task to receive and handle data from the taskpool worker thread.
289     *
290     * @param { Function } [callback] - Callback to be registered and executed later on the host side.
291     * @throws { BusinessError } 401 - The input parameters are invalid.
292     * @syscap SystemCapability.Utils.Lang
293     * @crossplatform
294     * @atomicservice
295     * @since 11
296     */
297    onReceiveData(callback?: Function): void;
298
299    /**
300     * Add dependencies on the task array for this task.
301     *
302     * @param { Task[] } tasks - tasks tasks An array of dependent tasks.
303     * @throws { BusinessError } 401 - The input parameters are invalid.
304     * @throws { BusinessError } 10200026 - There is a circular dependency.
305     * @syscap SystemCapability.Utils.Lang
306     * @crossplatform
307     * @atomicservice
308     * @since 11
309     */
310    addDependency(...tasks: Task[]): void;
311
312    /**
313     * Remove dependencies on the task array for this task.
314     *
315     * @param { Task[] } tasks - tasks tasks An array of dependent tasks.
316     * @throws { BusinessError } 401 - The input parameters are invalid.
317     * @throws { BusinessError } 10200027 - The dependency does not exist.
318     * @syscap SystemCapability.Utils.Lang
319     * @crossplatform
320     * @atomicservice
321     * @since 11
322     */
323    removeDependency(...tasks: Task[]): void;
324
325    /**
326     * Concurrent function to execute in taskpool.
327     *
328     * @syscap SystemCapability.Utils.Lang
329     * @since 9
330     */
331    /**
332     * Concurrent function to execute in taskpool.
333     *
334     * @syscap SystemCapability.Utils.Lang
335     * @crossplatform
336     * @since 10
337     */
338    /**
339     * Concurrent function to execute in taskpool.
340     *
341     * @syscap SystemCapability.Utils.Lang
342     * @crossplatform
343     * @atomicservice
344     * @since 11
345     */
346    function: Function;
347
348    /**
349     * The concurrent function arguments.
350     *
351     * @syscap SystemCapability.Utils.Lang
352     * @since 9
353     */
354    /**
355     * The concurrent function arguments.
356     *
357     * @type { ?unknown[] }
358     * @syscap SystemCapability.Utils.Lang
359     * @crossplatform
360     * @since 10
361     */
362    /**
363     * The concurrent function arguments.
364     *
365     * @type { ?Object[] }
366     * @syscap SystemCapability.Utils.Lang
367     * @crossplatform
368     * @atomicservice
369     * @since 11
370     */
371    arguments?: Object[];
372
373    /**
374     * Task name.
375     *
376     * @syscap SystemCapability.Utils.Lang
377     * @crossplatform
378     * @atomicservice
379     * @since 11
380     */
381    name: string;
382
383    /**
384     * Total duration of task execution.
385     *
386     * @type { number }
387     * @default 0
388     * @syscap SystemCapability.Utils.Lang
389     * @crossplatform
390     * @atomicservice
391     * @since 11
392     */
393    totalDuration: number;
394
395    /**
396     * IO duration of task execution.
397     *
398     * @type { number }
399     * @default 0
400     * @syscap SystemCapability.Utils.Lang
401     * @crossplatform
402     * @atomicservice
403     * @since 11
404     */
405    ioDuration: number;
406
407    /**
408     * CPU duration of task execution.
409     *
410     * @type { number }
411     * @default 0
412     * @syscap SystemCapability.Utils.Lang
413     * @crossplatform
414     * @atomicservice
415     * @since 11
416     */
417    cpuDuration: number;
418  }
419
420  /**
421   * The TaskGroup class provides an interface to create a task group.
422   *
423   * @syscap SystemCapability.Utils.Lang
424   * @crossplatform
425   * @since 10
426   */
427  /**
428   * The TaskGroup class provides an interface to create a task group.
429   *
430   * @syscap SystemCapability.Utils.Lang
431   * @crossplatform
432   * @atomicservice
433   * @since 11
434   */
435  class TaskGroup {
436    /**
437     * Create a TaskGroup instance.
438     *
439     * @syscap SystemCapability.Utils.Lang
440     * @crossplatform
441     * @since 10
442     */
443    /**
444     * Create a TaskGroup instance.
445     *
446     * @syscap SystemCapability.Utils.Lang
447     * @crossplatform
448     * @atomicservice
449     * @since 11
450     */
451    constructor();
452
453    /**
454     * Create a TaskGroup instance.
455     *
456     * @param { string } name - name name The name of taskGroup.
457     * @throws { BusinessError } 401 - The input parameters are invalid.
458     * @syscap SystemCapability.Utils.Lang
459     * @crossplatform
460     * @atomicservice
461     * @since 11
462     */
463    constructor(name: string);
464
465    /**
466     * Add a Concurrent function into task group.
467     *
468     * @param { Function } func - func func Concurrent function to add in task group.
469     * @param { unknown[] } args - args args The concurrent function arguments.
470     * @throws { BusinessError } 401 - The input parameters are invalid.
471     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
472     * @syscap SystemCapability.Utils.Lang
473     * @crossplatform
474     * @since 10
475     */
476    /**
477     * Add a Concurrent function into task group.
478     *
479     * @param { Function } func - func func Concurrent function to add in task group.
480     * @param { Object[] } args - args args The concurrent function arguments.
481     * @throws { BusinessError } 401 - The input parameters are invalid.
482     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
483     * @syscap SystemCapability.Utils.Lang
484     * @crossplatform
485     * @atomicservice
486     * @since 11
487     */
488    addTask(func: Function, ...args: Object[]): void;
489
490    /**
491     * Add a Task into TaskGroup.
492     *
493     * @param { Task } task - task task The task want to add in task group.
494     * @throws { BusinessError } 401 - The input parameters are invalid.
495     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
496     * @syscap SystemCapability.Utils.Lang
497     * @crossplatform
498     * @since 10
499     */
500    /**
501     * Add a Task into TaskGroup.
502     *
503     * @param { Task } task - task task The task want to add in task group.
504     * @throws { BusinessError } 401 - The input parameters are invalid.
505     * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
506     * @syscap SystemCapability.Utils.Lang
507     * @crossplatform
508     * @atomicservice
509     * @since 11
510     */
511    addTask(task: Task): void;
512
513    /**
514     * TaskGroup name.
515     *
516     * @syscap SystemCapability.Utils.Lang
517     * @crossplatform
518     * @atomicservice
519     * @since 11
520     */
521    name: string;
522  }
523
524  /**
525   * The SequenceRunner class provides an interface to create a task sequence runner.
526   *
527   * @syscap SystemCapability.Utils.Lang
528   * @crossplatform
529   * @atomicservice
530   * @since 11
531   */
532  class SequenceRunner {
533    /**
534     * Create a SequenceRunner instance.
535     *
536     * @param { Priority } priority - Task execution priority, MEDIUM is default.
537     * @throws { BusinessError } 401 - The input parameters are invalid.
538     * @syscap SystemCapability.Utils.Lang
539     * @crossplatform
540     * @atomicservice
541     * @since 11
542     */
543    constructor(priority?: Priority);
544
545    /**
546     * Execute a concurrent function.
547     *
548     * @param { Task } task - The task want to execute.
549     * @returns { Promise<Object> }
550     * @throws { BusinessError } 401 - The input parameters are invalid.
551     * @throws { BusinessError } 10200003 - Worker initialization failure.
552     * @throws { BusinessError } 10200006 - An exception occurred during serialization.
553     * @throws { BusinessError } 10200025 - Add dependent task to SequenceRunner.
554     * @syscap SystemCapability.Utils.Lang
555     * @crossplatform
556     * @atomicservice
557     * @since 11
558     */
559    execute(task: Task): Promise<Object>;
560  }
561
562  /**
563   * The State defines the task state.
564   *
565   * @enum { number } State
566   * @syscap SystemCapability.Utils.Lang
567   * @crossplatform
568   * @since 10
569   */
570  /**
571   * The State defines the task state.
572   *
573   * @enum { number } State
574   * @syscap SystemCapability.Utils.Lang
575   * @crossplatform
576   * @atomicservice
577   * @since 11
578   */
579  enum State {
580    /**
581     * the task state is waiting.
582     *
583     * @syscap SystemCapability.Utils.Lang
584     * @crossplatform
585     * @since 10
586     */
587    /**
588     * the task state is waiting.
589     *
590     * @syscap SystemCapability.Utils.Lang
591     * @crossplatform
592     * @atomicservice
593     * @since 11
594     */
595    WAITING = 1,
596
597    /**
598     * the task state is running.
599     *
600     * @syscap SystemCapability.Utils.Lang
601     * @crossplatform
602     * @since 10
603     */
604    /**
605     * the task state is running.
606     *
607     * @syscap SystemCapability.Utils.Lang
608     * @crossplatform
609     * @atomicservice
610     * @since 11
611     */
612    RUNNING = 2,
613
614    /**
615     * the task state is canceled.
616     *
617     * @syscap SystemCapability.Utils.Lang
618     * @crossplatform
619     * @since 10
620     */
621    /**
622     * the task state is canceled.
623     *
624     * @syscap SystemCapability.Utils.Lang
625     * @crossplatform
626     * @atomicservice
627     * @since 11
628     */
629    CANCELED = 3
630  }
631
632  /**
633   * Indicates the internal information of the worker thread.
634   *
635   * @syscap SystemCapability.Utils.Lang
636   * @crossplatform
637   * @since 10
638   */
639  /**
640   * Indicates the internal information of the worker thread.
641   *
642   * @syscap SystemCapability.Utils.Lang
643   * @crossplatform
644   * @atomicservice
645   * @since 11
646   */
647  class TaskInfo {
648    /**
649     * Task identity.
650     *
651     * @type { number }
652     * @default 0
653     * @syscap SystemCapability.Utils.Lang
654     * @crossplatform
655     * @since 10
656     */
657    /**
658     * Task identity.
659     *
660     * @type { number }
661     * @default 0
662     * @syscap SystemCapability.Utils.Lang
663     * @crossplatform
664     * @atomicservice
665     * @since 11
666     */
667    taskId: number;
668
669    /**
670     * Task state.
671     *
672     * @type { State }
673     * @default State::WAITING
674     * @syscap SystemCapability.Utils.Lang
675     * @crossplatform
676     * @since 10
677     */
678    /**
679     * Task state.
680     *
681     * @type { State }
682     * @default State::WAITING
683     * @syscap SystemCapability.Utils.Lang
684     * @crossplatform
685     * @atomicservice
686     * @since 11
687     */
688    state: State;
689
690    /**
691     * Duration of task execution.
692     *
693     * @type { ?number }
694     * @syscap SystemCapability.Utils.Lang
695     * @crossplatform
696     * @since 10
697     */
698    /**
699     * Duration of task execution.
700     *
701     * @type { ?number }
702     * @syscap SystemCapability.Utils.Lang
703     * @crossplatform
704     * @atomicservice
705     * @since 11
706     */
707    duration?: number;
708  }
709
710  /**
711   * Indicates the internal information of the worker thread.
712   *
713   * @syscap SystemCapability.Utils.Lang
714   * @crossplatform
715   * @since 10
716   */
717  /**
718   * Indicates the internal information of the worker thread.
719   *
720   * @syscap SystemCapability.Utils.Lang
721   * @crossplatform
722   * @atomicservice
723   * @since 11
724   */
725  class ThreadInfo {
726    /**
727     * Thread id.
728     *
729     * @type { number }
730     * @default 0
731     * @syscap SystemCapability.Utils.Lang
732     * @crossplatform
733     * @since 10
734     */
735    /**
736     * Thread id.
737     *
738     * @type { number }
739     * @default 0
740     * @syscap SystemCapability.Utils.Lang
741     * @crossplatform
742     * @atomicservice
743     * @since 11
744     */
745    tid: number;
746
747    /**
748     * Task id list that running on current thread.
749     *
750     * @type { ?number[] }
751     * @syscap SystemCapability.Utils.Lang
752     * @crossplatform
753     * @since 10
754     */
755    /**
756     * Task id list that running on current thread.
757     *
758     * @type { ?number[] }
759     * @syscap SystemCapability.Utils.Lang
760     * @crossplatform
761     * @atomicservice
762     * @since 11
763     */
764    taskIds?: number[];
765
766    /**
767     * Thread priority.
768     *
769     * @type { ?Priority }
770     * @syscap SystemCapability.Utils.Lang
771     * @crossplatform
772     * @since 10
773     */
774    /**
775     * Thread priority.
776     *
777     * @type { ?Priority }
778     * @syscap SystemCapability.Utils.Lang
779     * @crossplatform
780     * @atomicservice
781     * @since 11
782     */
783    priority?: Priority;
784  }
785
786  /**
787   * Indicates the internal information of the taskpool.
788   *
789   * @syscap SystemCapability.Utils.Lang
790   * @crossplatform
791   * @since 10
792   */
793  /**
794   * Indicates the internal information of the taskpool.
795   *
796   * @syscap SystemCapability.Utils.Lang
797   * @crossplatform
798   * @atomicservice
799   * @since 11
800   */
801  class TaskPoolInfo {
802    /**
803     * An array of taskpool thread information.
804     *
805     * @type { ThreadInfo[] }
806     * @syscap SystemCapability.Utils.Lang
807     * @crossplatform
808     * @since 10
809     */
810    /**
811     * An array of taskpool thread information.
812     *
813     * @type { ThreadInfo[] }
814     * @syscap SystemCapability.Utils.Lang
815     * @crossplatform
816     * @atomicservice
817     * @since 11
818     */
819    threadInfos: ThreadInfo[];
820
821    /**
822     * An array of taskpool task information.
823     *
824     * @type { TaskInfo[] }
825     * @syscap SystemCapability.Utils.Lang
826     * @crossplatform
827     * @since 10
828     */
829    /**
830     * An array of taskpool task information.
831     *
832     * @type { TaskInfo[] }
833     * @syscap SystemCapability.Utils.Lang
834     * @crossplatform
835     * @atomicservice
836     * @since 11
837     */
838    taskInfos: TaskInfo[];
839  }
840
841  /**
842   * Execute a concurrent function.
843   *
844   * @param { Function } func - func func Concurrent function want to execute.
845   * @param { unknown[] } args - args args The concurrent function arguments.
846   * @returns { Promise<unknown> }
847   * @throws { BusinessError } 401 - The input parameters are invalid.
848   * @throws { BusinessError } 10200003 - Worker initialization failure.
849   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
850   * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
851   * @syscap SystemCapability.Utils.Lang
852   * @since 9
853   */
854  /**
855   * Execute a concurrent function.
856   *
857   * @param { Function } func - func func Concurrent function want to execute.
858   * @param { unknown[] } args - args args The concurrent function arguments.
859   * @returns { Promise<unknown> }
860   * @throws { BusinessError } 401 - The input parameters are invalid.
861   * @throws { BusinessError } 10200003 - Worker initialization failure.
862   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
863   * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
864   * @syscap SystemCapability.Utils.Lang
865   * @crossplatform
866   * @since 10
867   */
868  /**
869   * Execute a concurrent function.
870   *
871   * @param { Function } func - func func Concurrent function want to execute.
872   * @param { Object[] } args - args args The concurrent function arguments.
873   * @returns { Promise<Object> }
874   * @throws { BusinessError } 401 - The input parameters are invalid.
875   * @throws { BusinessError } 10200003 - Worker initialization failure.
876   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
877   * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
878   * @syscap SystemCapability.Utils.Lang
879   * @crossplatform
880   * @atomicservice
881   * @since 11
882   */
883  function execute(func: Function, ...args: Object[]): Promise<Object>;
884
885  /**
886   * Execute a concurrent task.
887   *
888   * @param { Task } task - task task The task want to execute.
889   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
890   * @returns { Promise<unknown> }
891   * @throws { BusinessError } 401 - The input parameters are invalid.
892   * @throws { BusinessError } 10200003 - Worker initialization failure.
893   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
894   * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
895   * @syscap SystemCapability.Utils.Lang
896   * @since 9
897   */
898  /**
899   * Execute a concurrent task.
900   *
901   * @param { Task } task - task task The task want to execute.
902   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
903   * @returns { Promise<unknown> }
904   * @throws { BusinessError } 401 - The input parameters are invalid.
905   * @throws { BusinessError } 10200003 - Worker initialization failure.
906   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
907   * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
908   * @syscap SystemCapability.Utils.Lang
909   * @crossplatform
910   * @since 10
911   */
912  /**
913   * Execute a concurrent task.
914   *
915   * @param { Task } task - task task The task want to execute.
916   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
917   * @returns { Promise<Object> }
918   * @throws { BusinessError } 401 - The input parameters are invalid.
919   * @throws { BusinessError } 10200003 - Worker initialization failure.
920   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
921   * @throws { BusinessError } 10200014 - The function is not mark as concurrent.
922   * @syscap SystemCapability.Utils.Lang
923   * @crossplatform
924   * @atomicservice
925   * @since 11
926   */
927  function execute(task: Task, priority?: Priority): Promise<Object>;
928
929  /**
930   * Execute a concurrent task group.
931   *
932   * @param { TaskGroup } group - group group The task group want to execute.
933   * @param { Priority } [priority] - priority priority Task group priority, MEDIUM is default.
934   * @returns { Promise<unknown[]> }
935   * @throws { BusinessError } 401 - The input parameters are invalid.
936   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
937   * @syscap SystemCapability.Utils.Lang
938   * @crossplatform
939   * @since 10
940   */
941  /**
942   * Execute a concurrent task group.
943   *
944   * @param { TaskGroup } group - group group The task group want to execute.
945   * @param { Priority } [priority] - priority priority Task group priority, MEDIUM is default.
946   * @returns { Promise<Object[]> }
947   * @throws { BusinessError } 401 - The input parameters are invalid.
948   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
949   * @syscap SystemCapability.Utils.Lang
950   * @crossplatform
951   * @atomicservice
952   * @since 11
953   */
954  function execute(group: TaskGroup, priority?: Priority): Promise<Object[]>;
955
956  /**
957   * Execute a concurrent task after the specified time.
958   *
959   * @param { number } delayTime - delayTime delayTime The time want to delay.
960   * @param { Task } task - task task The task want to execute.
961   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
962   * @returns { Promise<Object> }
963   * @throws { BusinessError } 401 - The input parameters are invalid.
964   * @throws { BusinessError } 10200028 - The delayTime is less than zero.
965   * @syscap SystemCapability.Utils.Lang
966   * @crossplatform
967   * @atomicservice
968   * @since 11
969   */
970  function executeDelayed(delayTime: number, task: Task, priority?: Priority): Promise<Object>;
971
972  /**
973   * Cancel a concurrent task.
974   *
975   * @param { Task } task - task task The task want to cancel.
976   * @throws { BusinessError } 401 - The input parameters are invalid.
977   * @throws { BusinessError } 10200015 - The task does not exist when it is canceled.
978   * @throws { BusinessError } 10200016 - The task is executing when it is canceled.
979   * @syscap SystemCapability.Utils.Lang
980   * @since 9
981   */
982  /**
983   * Cancel a concurrent task.
984   *
985   * @param { Task } task - task task The task want to cancel.
986   * @throws { BusinessError } 401 - The input parameters are invalid.
987   * @throws { BusinessError } 10200015 - The task does not exist when it is canceled.
988   * @syscap SystemCapability.Utils.Lang
989   * @crossplatform
990   * @since 10
991   */
992  /**
993   * Cancel a concurrent task.
994   *
995   * @param { Task } task - task task The task want to cancel.
996   * @throws { BusinessError } 401 - The input parameters are invalid.
997   * @throws { BusinessError } 10200015 - The task does not exist when it is canceled.
998   * @syscap SystemCapability.Utils.Lang
999   * @crossplatform
1000   * @atomicservice
1001   * @since 11
1002   */
1003  function cancel(task: Task): void;
1004
1005  /**
1006   * Cancel a concurrent task group.
1007   *
1008   * @param { TaskGroup } group - group group The task group want to cancel.
1009   * @throws { BusinessError } 401 - The input parameters are invalid.
1010   * @throws { BusinessError } 10200018 - The task group does not exist when it is canceled.
1011   * @syscap SystemCapability.Utils.Lang
1012   * @crossplatform
1013   * @since 10
1014   */
1015  /**
1016   * Cancel a concurrent task group.
1017   *
1018   * @param { TaskGroup } group - group group The task group want to cancel.
1019   * @throws { BusinessError } 401 - The input parameters are invalid.
1020   * @throws { BusinessError } 10200018 - The task group does not exist when it is canceled.
1021   * @syscap SystemCapability.Utils.Lang
1022   * @crossplatform
1023   * @atomicservice
1024   * @since 11
1025   */
1026  function cancel(group: TaskGroup): void;
1027
1028  /**
1029   * Get task pool internal information.
1030   *
1031   * @returns { TaskPoolInfo }
1032   * @syscap SystemCapability.Utils.Lang
1033   * @crossplatform
1034   * @since 10
1035   */
1036  /**
1037   * Get task pool internal information.
1038   *
1039   * @returns { TaskPoolInfo }
1040   * @syscap SystemCapability.Utils.Lang
1041   * @crossplatform
1042   * @atomicservice
1043   * @since 11
1044   */
1045  function getTaskPoolInfo(): TaskPoolInfo;
1046}
1047
1048export default taskpool;
1049