• 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     * set task priority to idle.
141     *
142     * @syscap SystemCapability.Utils.Lang
143     * @crossplatform
144     * @atomicservice
145     * @since 12
146     */
147    IDLE = 3
148  }
149
150  /**
151   * Indicates the type of callback to be registered.
152   *
153   * @typedef { function } CallbackFunction
154   * @syscap SystemCapability.Utils.Lang
155   * @crossplatform
156   * @atomicservice
157   * @since 12
158   */
159  type CallbackFunction = () => void;
160
161  /**
162   * Indicates the type of callback with error code to be registered.
163   *
164   * @typedef { function } CallbackFunctionWithError
165   * @param { Error } e - the error message.
166   * @syscap SystemCapability.Utils.Lang
167   * @crossplatform
168   * @atomicservice
169   * @since 12
170   */
171  type CallbackFunctionWithError = (e: Error) => void;
172
173  /**
174   * The Task class provides an interface to create a task.
175   *
176   * @syscap SystemCapability.Utils.Lang
177   * @since 9
178   */
179  /**
180   * The Task class provides an interface to create a task.
181   *
182   * @syscap SystemCapability.Utils.Lang
183   * @crossplatform
184   * @since 10
185   */
186  /**
187   * The Task class provides an interface to create a task.
188   *
189   * @syscap SystemCapability.Utils.Lang
190   * @crossplatform
191   * @atomicservice
192   * @since 11
193   */
194  class Task {
195    /**
196     * Create a Task instance.
197     *
198     * @param { Function } func - func func Concurrent function to execute in taskpool.
199     * @param { unknown[] } args - args args The concurrent function arguments.
200     * @throws { BusinessError } 401 - The input parameters are invalid.
201     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
202     * @syscap SystemCapability.Utils.Lang
203     * @since 9
204     */
205    /**
206     * Create a Task instance.
207     *
208     * @param { Function } func - func func Concurrent function to execute in taskpool.
209     * @param { unknown[] } args - args args The concurrent function arguments.
210     * @throws { BusinessError } 401 - The input parameters are invalid.
211     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
212     * @syscap SystemCapability.Utils.Lang
213     * @crossplatform
214     * @since 10
215     */
216    /**
217     * Create a Task instance.
218     *
219     * @param { Function } func - func func Concurrent function to execute in taskpool.
220     * @param { Object[] } args - args args The concurrent function arguments.
221     * @throws { BusinessError } 401 - The input parameters are invalid.
222     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
223     * @syscap SystemCapability.Utils.Lang
224     * @crossplatform
225     * @atomicservice
226     * @since 11
227     */
228    constructor(func: Function, ...args: Object[]);
229
230    /**
231     * Create a Task instance.
232     *
233     * @param { string } name - name name The name of Task.
234     * @param { Function } func - func func Concurrent function to execute in taskpool.
235     * @param { Object[] } args - args args The concurrent function arguments.
236     * @throws { BusinessError } 401 - The input parameters are invalid.
237     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
238     * @syscap SystemCapability.Utils.Lang
239     * @crossplatform
240     * @atomicservice
241     * @since 11
242     */
243    constructor(name: string, func: Function, ...args: Object[]);
244
245    /**
246     * Check current running Task is canceled or not.
247     *
248     * @returns { boolean } Returns {@code true} if current running task is canceled; returns {@code false} otherwise.
249     * @static
250     * @syscap SystemCapability.Utils.Lang
251     * @crossplatform
252     * @since 10
253     */
254    /**
255     * Check current running Task is canceled or not.
256     *
257     * @returns { boolean } Returns {@code true} if current running task is canceled; returns {@code false} otherwise.
258     * @static
259     * @syscap SystemCapability.Utils.Lang
260     * @crossplatform
261     * @atomicservice
262     * @since 11
263     */
264    static isCanceled(): boolean;
265
266    /**
267     * Send data back to the host side and trigger the registered callback
268     *
269     * @param { Object[] } args - Data to be used as the input parameter of the registered callback.
270     * @throws { BusinessError } 401 - The input parameters are invalid.
271     * @throws { BusinessError } 10200006 - An exception occurred during serialization.
272     * @throws { BusinessError } 10200022 - The function is not called in the TaskPool thread.
273     * @throws { BusinessError } 10200023 - The function is not called in the concurrent function.
274     * @throws { BusinessError } 10200024 - The callback is not registered on the host side.
275     * @static
276     * @syscap SystemCapability.Utils.Lang
277     * @crossplatform
278     * @atomicservice
279     * @since 11
280     */
281    static sendData(...args: Object[]): void;
282
283    /**
284     * Set transfer list for this task.
285     *
286     * @param { ArrayBuffer[] } [transfer] - transfer Transfer list of this task, empty array is default.
287     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
288     * @syscap SystemCapability.Utils.Lang
289     * @crossplatform
290     * @since 10
291     */
292    /**
293     * Set transfer list for this task.
294     *
295     * @param { ArrayBuffer[] } [transfer] - transfer Transfer list of this task, empty array is default.
296     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
297     * @throws { BusinessError } 10200029 - An ArrayBuffer cannot be set as both a transfer list and a clone list.
298     * @syscap SystemCapability.Utils.Lang
299     * @crossplatform
300     * @atomicservice
301     * @since 11
302     */
303    setTransferList(transfer?: ArrayBuffer[]): void;
304
305    /**
306     * Set clone list for this task.
307     *
308     * @param { Object[] | ArrayBuffer[] } cloneList - Sendable objects or arrayBuffer objects in this list
309     * will be transmitted to worker thread in a copy way.
310     * @throws { BusinessError } 401 - Parameter error. Possible causes:
311     * 1.Mandatory parameters are left unspecified;
312     * 2.Incorrect parameter types;
313     * 3.Parameter verification failed.
314     * @throws { BusinessError } 10200029 - An ArrayBuffer cannot be set as both a transfer list and a clone list.
315     * @syscap SystemCapability.Utils.Lang
316     * @crossplatform
317     * @atomicservice
318     * @since 11
319     */
320    setCloneList(cloneList: Object[] | ArrayBuffer[]): void;
321
322    /**
323     * Register a callback for this task to receive and handle data from the taskpool worker thread.
324     *
325     * @param { Function } [callback] - Callback to be registered and executed later on the host side.
326     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
327     * @syscap SystemCapability.Utils.Lang
328     * @crossplatform
329     * @atomicservice
330     * @since 11
331     */
332    onReceiveData(callback?: Function): void;
333
334    /**
335     * Add dependencies on the task array for this task.
336     *
337     * @param { Task[] } tasks - tasks tasks An array of dependent tasks.
338     * @throws { BusinessError } 401 - Parameter error. Possible causes:
339     * 1.Mandatory parameters are left unspecified;
340     * 2.Incorrect parameter types;
341     * 3.Parameter verification failed.
342     * @throws { BusinessError } 10200026 - There is a circular dependency.
343     * @syscap SystemCapability.Utils.Lang
344     * @crossplatform
345     * @atomicservice
346     * @since 11
347     */
348    /**
349     * Add dependencies on the task array for this task.
350     *
351     * @param { Task[] } tasks - An array of dependent tasks.
352     * @throws { BusinessError } 401 - Parameter error. Possible causes:
353     * <br>1. Mandatory parameters are left unspecified;
354     * <br>2. Incorrect parameter types;
355     * <br>3. Parameter verification failed.
356     * @throws { BusinessError } 10200026 - There is a circular dependency.
357     * @throws { BusinessError } 10200052 - The periodic task cannot have a dependency.
358     * @syscap SystemCapability.Utils.Lang
359     * @crossplatform
360     * @atomicservice
361     * @since 12
362     */
363    addDependency(...tasks: Task[]): void;
364
365    /**
366     * Remove dependencies on the task array for this task.
367     *
368     * @param { Task[] } tasks - tasks tasks An array of dependent tasks.
369     * @throws { BusinessError } 401 - Parameter error. Possible causes:
370     * 1.Mandatory parameters are left unspecified;
371     * 2.Incorrect parameter types;
372     * 3.Parameter verification failed.
373     * @throws { BusinessError } 10200027 - The dependency does not exist.
374     * @syscap SystemCapability.Utils.Lang
375     * @crossplatform
376     * @atomicservice
377     * @since 11
378     */
379    /**
380     * Remove dependencies on the task array for this task.
381     *
382     * @param { Task[] } tasks - An array of dependent tasks.
383     * @throws { BusinessError } 401 - Parameter error. Possible causes:
384     * <br>1. Mandatory parameters are left unspecified;
385     * <br>2. Incorrect parameter types;
386     * <br>3. Parameter verification failed.
387     * @throws { BusinessError } 10200027 - The dependency does not exist.
388     * @throws { BusinessError } 10200052 - The periodic task cannot have a dependency.
389     * @syscap SystemCapability.Utils.Lang
390     * @crossplatform
391     * @atomicservice
392     * @since 12
393     */
394    removeDependency(...tasks: Task[]): void;
395
396    /**
397     * Register a callback and call it when the task is enqueued.
398     *
399     * @param { CallbackFunction } [callback] - Callback to be registered and executed later on the host side.
400     * @throws { BusinessError } 401 - The input parameters are invalid.
401     * @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
402     * @syscap SystemCapability.Utils.Lang
403     * @crossplatform
404     * @atomicservice
405     * @since 12
406     */
407    onEnqueued(callback: CallbackFunction): void;
408
409    /**
410     * Register a callback and call it when the task before execute.
411     *
412     * @param { CallbackFunction } [callback] - Callback to be registered and executed later on the host side.
413     * @throws { BusinessError } 401 - The input parameters are invalid.
414     * @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
415     * @syscap SystemCapability.Utils.Lang
416     * @crossplatform
417     * @atomicservice
418     * @since 12
419     */
420    onStartExecution(callback: CallbackFunction): void;
421
422    /**
423     * Register a callback and call it when the task fails to execute.
424     *
425     * @param { CallbackFunctionWithError } [callback] - Callback to be registered and executed later on the host side.
426     * @throws { BusinessError } 401 - The input parameters are invalid.
427     * @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
428     * @syscap SystemCapability.Utils.Lang
429     * @crossplatform
430     * @atomicservice
431     * @since 12
432     */
433    onExecutionFailed(callback: CallbackFunctionWithError): void;
434
435    /**
436     * Register a callback and call it when the task successfully executes.
437     *
438     * @param { CallbackFunction } [callback] - Callback to be registered and executed later on the host side.
439     * @throws { BusinessError } 401 - The input parameters are invalid.
440     * @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
441     * @syscap SystemCapability.Utils.Lang
442     * @crossplatform
443     * @atomicservice
444     * @since 12
445     */
446    onExecutionSucceeded(callback: CallbackFunction): void;
447
448    /**
449     * Check if the task has been completed.
450     *
451     * @returns { boolean } Returns {@code true} if the task has been completed; returns {@code false} otherwise.
452     * @syscap SystemCapability.Utils.Lang
453     * @crossplatform
454     * @atomicservice
455     * @since 12
456     */
457    isDone(): boolean;
458
459    /**
460     * Concurrent function to execute in taskpool.
461     *
462     * @type { Function }
463     * @syscap SystemCapability.Utils.Lang
464     * @since 9
465     */
466    /**
467     * Concurrent function to execute in taskpool.
468     *
469     * @type { Function }
470     * @syscap SystemCapability.Utils.Lang
471     * @crossplatform
472     * @since 10
473     */
474    /**
475     * Concurrent function to execute in taskpool.
476     *
477     * @type { Function }
478     * @syscap SystemCapability.Utils.Lang
479     * @crossplatform
480     * @atomicservice
481     * @since 11
482     */
483    function: Function;
484
485    /**
486     * The concurrent function arguments.
487     *
488     * @syscap SystemCapability.Utils.Lang
489     * @since 9
490     */
491    /**
492     * The concurrent function arguments.
493     *
494     * @type { ?unknown[] }
495     * @syscap SystemCapability.Utils.Lang
496     * @crossplatform
497     * @since 10
498     */
499    /**
500     * The concurrent function arguments.
501     *
502     * @type { ?Object[] }
503     * @syscap SystemCapability.Utils.Lang
504     * @crossplatform
505     * @atomicservice
506     * @since 11
507     */
508    arguments?: Object[];
509
510    /**
511     * Task name.
512     *
513     * @type { string }
514     * @syscap SystemCapability.Utils.Lang
515     * @crossplatform
516     * @atomicservice
517     * @since 11
518     */
519    name: string;
520
521    /**
522     * Total duration of task execution.
523     *
524     * @type { number }
525     * @default 0
526     * @syscap SystemCapability.Utils.Lang
527     * @crossplatform
528     * @atomicservice
529     * @since 11
530     */
531    totalDuration: number;
532
533    /**
534     * IO duration of task execution.
535     *
536     * @type { number }
537     * @default 0
538     * @syscap SystemCapability.Utils.Lang
539     * @crossplatform
540     * @atomicservice
541     * @since 11
542     */
543    ioDuration: number;
544
545    /**
546     * CPU duration of task execution.
547     *
548     * @type { number }
549     * @default 0
550     * @syscap SystemCapability.Utils.Lang
551     * @crossplatform
552     * @atomicservice
553     * @since 11
554     */
555    cpuDuration: number;
556  }
557
558  /**
559   * The TaskGroup class provides an interface to create a task group.
560   *
561   * @syscap SystemCapability.Utils.Lang
562   * @crossplatform
563   * @since 10
564   */
565  /**
566   * The TaskGroup class provides an interface to create a task group.
567   *
568   * @syscap SystemCapability.Utils.Lang
569   * @crossplatform
570   * @atomicservice
571   * @since 11
572   */
573  class TaskGroup {
574    /**
575     * Create a TaskGroup instance.
576     *
577     * @syscap SystemCapability.Utils.Lang
578     * @crossplatform
579     * @since 10
580     */
581    /**
582     * Create a TaskGroup instance.
583     *
584     * @syscap SystemCapability.Utils.Lang
585     * @crossplatform
586     * @atomicservice
587     * @since 11
588     */
589    constructor();
590
591    /**
592     * Create a TaskGroup instance.
593     *
594     * @param { string } name - name name The name of taskGroup.
595     * @throws { BusinessError } 401 - Parameter error. Possible causes:
596     * 1.Mandatory parameters are left unspecified;
597     * 2.Incorrect parameter types;
598     * 3.Parameter verification failed.
599     * @syscap SystemCapability.Utils.Lang
600     * @crossplatform
601     * @atomicservice
602     * @since 11
603     */
604    constructor(name: string);
605
606    /**
607     * Add a Concurrent function into task group.
608     *
609     * @param { Function } func - func func Concurrent function to add in task group.
610     * @param { unknown[] } args - args args The concurrent function arguments.
611     * @throws { BusinessError } 401 - Parameter error. Possible causes:
612     * 1.Mandatory parameters are left unspecified;
613     * 2.Incorrect parameter types;
614     * 3.Parameter verification failed.
615     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
616     * @syscap SystemCapability.Utils.Lang
617     * @crossplatform
618     * @since 10
619     */
620    /**
621     * Add a Concurrent function into task group.
622     *
623     * @param { Function } func - func func Concurrent function to add in task group.
624     * @param { Object[] } args - args args The concurrent function arguments.
625     * @throws { BusinessError } 401 - Parameter error. Possible causes:
626     * 1.Mandatory parameters are left unspecified;
627     * 2.Incorrect parameter types;
628     * 3.Parameter verification failed.
629     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
630     * @syscap SystemCapability.Utils.Lang
631     * @crossplatform
632     * @atomicservice
633     * @since 11
634     */
635    addTask(func: Function, ...args: Object[]): void;
636
637    /**
638     * Add a Task into TaskGroup.
639     *
640     * @param { Task } task - task task The task want to add in task group.
641     * @throws { BusinessError } 401 - Parameter error. Possible causes:
642     * 1.Mandatory parameters are left unspecified;
643     * 2.Incorrect parameter types;
644     * 3.Parameter verification failed.
645     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
646     * @syscap SystemCapability.Utils.Lang
647     * @crossplatform
648     * @since 10
649     */
650    /**
651     * Add a Task into TaskGroup.
652     *
653     * @param { Task } task - task task The task want to add in task group.
654     * @throws { BusinessError } 401 - Parameter error. Possible causes:
655     * 1.Mandatory parameters are left unspecified;
656     * 2.Incorrect parameter types;
657     * 3.Parameter verification failed.
658     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
659     * @syscap SystemCapability.Utils.Lang
660     * @crossplatform
661     * @atomicservice
662     * @since 11
663     */
664    /**
665     * Add a Task into TaskGroup.
666     *
667     * @param { Task } task - The task want to add in task group.
668     * @throws { BusinessError } 401 - Parameter error. Possible causes:
669     * <br>1. Mandatory parameters are left unspecified;
670     * <br>2. Incorrect parameter types;
671     * <br>3. Parameter verification failed.
672     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
673     * @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
674     * @syscap SystemCapability.Utils.Lang
675     * @crossplatform
676     * @atomicservice
677     * @since 12
678     */
679    addTask(task: Task): void;
680
681    /**
682     * TaskGroup name.
683     *
684     * @type { string }
685     * @syscap SystemCapability.Utils.Lang
686     * @crossplatform
687     * @atomicservice
688     * @since 11
689     */
690    name: string;
691  }
692
693  /**
694   * The SequenceRunner class provides an interface to create a task sequence runner.
695   *
696   * @syscap SystemCapability.Utils.Lang
697   * @crossplatform
698   * @atomicservice
699   * @since 11
700   */
701  class SequenceRunner {
702    /**
703     * Create a SequenceRunner instance.
704     *
705     * @param { Priority } priority - Task execution priority, MEDIUM is default.
706     * @throws { BusinessError } 401 - Parameter error. Possible causes:
707     * 1.Incorrect parameter types;
708     * 2.Parameter verification failed.
709     * @syscap SystemCapability.Utils.Lang
710     * @crossplatform
711     * @atomicservice
712     * @since 11
713     */
714    constructor(priority?: Priority);
715
716    /**
717     * Create or get a SequenceRunner instance by name.
718     *
719     * @param { string } name - SequenceRunner name, if name is the same, will return the same SequenceRunner.
720     * @param { Priority } priority - Task execution priority, MEDIUM is default.
721     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
722     * <br>2. Incorrect parameter types. 3.Parameter verification failed.
723     * @syscap SystemCapability.Utils.Lang
724     * @crossplatform
725     * @atomicservice
726     * @since 12
727     */
728    constructor(name: string, priority?: Priority);
729
730    /**
731     * Execute a concurrent function.
732     *
733     * @param { Task } task - The task want to execute.
734     * @returns { Promise<Object> }
735     * @throws { BusinessError } 401 - Parameter error. Possible causes:
736     * 1.Mandatory parameters are left unspecified;
737     * 2.Incorrect parameter types;
738     * @throws { BusinessError } 10200003 - Worker initialization failed.
739     * @throws { BusinessError } 10200006 - An exception occurred during serialization.
740     * @throws { BusinessError } 10200025 - The task to be added to SequenceRunner has dependent tasks.
741     * @syscap SystemCapability.Utils.Lang
742     * @crossplatform
743     * @atomicservice
744     * @since 11
745     */
746    /**
747     * Execute a concurrent function.
748     *
749     * @param { Task } task - The task want to execute.
750     * @returns { Promise<Object> }
751     * @throws { BusinessError } 401 - Parameter error. Possible causes:
752     * <br>1. Mandatory parameters are left unspecified;
753     * <br>2. Incorrect parameter types;
754     * @throws { BusinessError } 10200006 - An exception occurred during serialization.
755     * @throws { BusinessError } 10200025 - dependent task not allowed.
756     * @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
757     * @syscap SystemCapability.Utils.Lang
758     * @crossplatform
759     * @atomicservice
760     * @since 12
761     */
762    execute(task: Task): Promise<Object>;
763  }
764
765  /**
766   * The LongTask class provides an interface to create a task that has no upper limit on execution time.
767   *
768   * @extends Task
769   * @syscap SystemCapability.Utils.Lang
770   * @crossplatform
771   * @atomicservice
772   * @since 12
773   */
774  class LongTask extends Task {
775  }
776
777  /**
778   * The GenericsTask class provides an interface to create a task with generics.
779   *
780   * @extends Task
781   * @syscap SystemCapability.Utils.Lang
782   * @atomicservice
783   * @since 13
784   */
785  class GenericsTask<A extends Array<Object>, R> extends Task {
786    /**
787     * Create a GenericsTask instance.
788     *
789     * @param { (...args: A) => R | Promise<R> } func - Concurrent function to execute in taskpool.
790     * @param { A } args - The concurrent function arguments.
791     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
792     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
793     * @syscap SystemCapability.Utils.Lang
794     * @atomicservice
795     * @since 13
796     */
797    constructor(func: (...args: A) => R | Promise<R>, ...args: A);
798
799    /**
800     * Create a GenericsTask instance.
801     *
802     * @param { string } name - The name of GenericsTask.
803     * @param { (...args: A) => R | Promise<R> } func - Concurrent function to execute in taskpool.
804     * @param { A } args - The concurrent function arguments.
805     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
806     * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
807     * @syscap SystemCapability.Utils.Lang
808     * @atomicservice
809     * @since 13
810     */
811    constructor(name: string, func: (...args: A) => R | Promise<R>, ...args: A);
812  }
813
814  /**
815   * The State defines the task state.
816   *
817   * @enum { number } State
818   * @syscap SystemCapability.Utils.Lang
819   * @crossplatform
820   * @since 10
821   */
822  /**
823   * The State defines the task state.
824   *
825   * @enum { number } State
826   * @syscap SystemCapability.Utils.Lang
827   * @crossplatform
828   * @atomicservice
829   * @since 11
830   */
831  enum State {
832    /**
833     * the task state is waiting.
834     *
835     * @syscap SystemCapability.Utils.Lang
836     * @crossplatform
837     * @since 10
838     */
839    /**
840     * the task state is waiting.
841     *
842     * @syscap SystemCapability.Utils.Lang
843     * @crossplatform
844     * @atomicservice
845     * @since 11
846     */
847    WAITING = 1,
848
849    /**
850     * the task state is running.
851     *
852     * @syscap SystemCapability.Utils.Lang
853     * @crossplatform
854     * @since 10
855     */
856    /**
857     * the task state is running.
858     *
859     * @syscap SystemCapability.Utils.Lang
860     * @crossplatform
861     * @atomicservice
862     * @since 11
863     */
864    RUNNING = 2,
865
866    /**
867     * the task state is canceled.
868     *
869     * @syscap SystemCapability.Utils.Lang
870     * @crossplatform
871     * @since 10
872     */
873    /**
874     * the task state is canceled.
875     *
876     * @syscap SystemCapability.Utils.Lang
877     * @crossplatform
878     * @atomicservice
879     * @since 11
880     */
881    CANCELED = 3
882  }
883
884  /**
885   * Indicates the internal information of the worker thread.
886   *
887   * @syscap SystemCapability.Utils.Lang
888   * @crossplatform
889   * @since 10
890   */
891  /**
892   * Indicates the internal information of the worker thread.
893   *
894   * @syscap SystemCapability.Utils.Lang
895   * @crossplatform
896   * @atomicservice
897   * @since 11
898   */
899  class TaskInfo {
900    /**
901     * Task identity.
902     *
903     * @type { number }
904     * @default 0
905     * @syscap SystemCapability.Utils.Lang
906     * @crossplatform
907     * @since 10
908     */
909    /**
910     * Task identity.
911     *
912     * @type { number }
913     * @default 0
914     * @syscap SystemCapability.Utils.Lang
915     * @crossplatform
916     * @atomicservice
917     * @since 11
918     */
919    taskId: number;
920
921    /**
922     * Task state.
923     *
924     * @type { State }
925     * @default State::WAITING
926     * @syscap SystemCapability.Utils.Lang
927     * @crossplatform
928     * @since 10
929     */
930    /**
931     * Task state.
932     *
933     * @type { State }
934     * @default State::WAITING
935     * @syscap SystemCapability.Utils.Lang
936     * @crossplatform
937     * @atomicservice
938     * @since 11
939     */
940    state: State;
941
942    /**
943     * Duration of task execution.
944     *
945     * @type { ?number }
946     * @syscap SystemCapability.Utils.Lang
947     * @crossplatform
948     * @since 10
949     */
950    /**
951     * Duration of task execution.
952     *
953     * @type { ?number }
954     * @syscap SystemCapability.Utils.Lang
955     * @crossplatform
956     * @atomicservice
957     * @since 11
958     */
959    duration?: number;
960
961    /**
962     * Task name.
963     *
964     * @type { string }
965     * @syscap SystemCapability.Utils.Lang
966     * @crossplatform
967     * @atomicservice
968     * @since 12
969     */
970     name: string;
971  }
972
973  /**
974   * Indicates the internal information of the worker thread.
975   *
976   * @syscap SystemCapability.Utils.Lang
977   * @crossplatform
978   * @since 10
979   */
980  /**
981   * Indicates the internal information of the worker thread.
982   *
983   * @syscap SystemCapability.Utils.Lang
984   * @crossplatform
985   * @atomicservice
986   * @since 11
987   */
988  class ThreadInfo {
989    /**
990     * Thread id.
991     *
992     * @type { number }
993     * @default 0
994     * @syscap SystemCapability.Utils.Lang
995     * @crossplatform
996     * @since 10
997     */
998    /**
999     * Thread id.
1000     *
1001     * @type { number }
1002     * @default 0
1003     * @syscap SystemCapability.Utils.Lang
1004     * @crossplatform
1005     * @atomicservice
1006     * @since 11
1007     */
1008    tid: number;
1009
1010    /**
1011     * Task id list that running on current thread.
1012     *
1013     * @type { ?number[] }
1014     * @syscap SystemCapability.Utils.Lang
1015     * @crossplatform
1016     * @since 10
1017     */
1018    /**
1019     * Task id list that running on current thread.
1020     *
1021     * @type { ?number[] }
1022     * @syscap SystemCapability.Utils.Lang
1023     * @crossplatform
1024     * @atomicservice
1025     * @since 11
1026     */
1027    taskIds?: number[];
1028
1029    /**
1030     * Thread priority.
1031     *
1032     * @type { ?Priority }
1033     * @syscap SystemCapability.Utils.Lang
1034     * @crossplatform
1035     * @since 10
1036     */
1037    /**
1038     * Thread priority.
1039     *
1040     * @type { ?Priority }
1041     * @syscap SystemCapability.Utils.Lang
1042     * @crossplatform
1043     * @atomicservice
1044     * @since 11
1045     */
1046    priority?: Priority;
1047  }
1048
1049  /**
1050   * Indicates the internal information of the taskpool.
1051   *
1052   * @syscap SystemCapability.Utils.Lang
1053   * @crossplatform
1054   * @since 10
1055   */
1056  /**
1057   * Indicates the internal information of the taskpool.
1058   *
1059   * @syscap SystemCapability.Utils.Lang
1060   * @crossplatform
1061   * @atomicservice
1062   * @since 11
1063   */
1064  class TaskPoolInfo {
1065    /**
1066     * An array of taskpool thread information.
1067     *
1068     * @type { ThreadInfo[] }
1069     * @syscap SystemCapability.Utils.Lang
1070     * @crossplatform
1071     * @since 10
1072     */
1073    /**
1074     * An array of taskpool thread information.
1075     *
1076     * @type { ThreadInfo[] }
1077     * @syscap SystemCapability.Utils.Lang
1078     * @crossplatform
1079     * @atomicservice
1080     * @since 11
1081     */
1082    threadInfos: ThreadInfo[];
1083
1084    /**
1085     * An array of taskpool task information.
1086     *
1087     * @type { TaskInfo[] }
1088     * @syscap SystemCapability.Utils.Lang
1089     * @crossplatform
1090     * @since 10
1091     */
1092    /**
1093     * An array of taskpool task information.
1094     *
1095     * @type { TaskInfo[] }
1096     * @syscap SystemCapability.Utils.Lang
1097     * @crossplatform
1098     * @atomicservice
1099     * @since 11
1100     */
1101    taskInfos: TaskInfo[];
1102  }
1103
1104  /**
1105   * Execute a concurrent function.
1106   *
1107   * @param { Function } func - func func Concurrent function want to execute.
1108   * @param { unknown[] } args - args args The concurrent function arguments.
1109   * @returns { Promise<unknown> }
1110   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1111   * 1.Mandatory parameters are left unspecified;
1112   * 2.Incorrect parameter types;
1113   * 3.Parameter verification failed.
1114   * @throws { BusinessError } 10200003 - Worker initialization failed.
1115   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1116   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1117   * @syscap SystemCapability.Utils.Lang
1118   * @since 9
1119   */
1120  /**
1121   * Execute a concurrent function.
1122   *
1123   * @param { Function } func - func func Concurrent function want to execute.
1124   * @param { unknown[] } args - args args The concurrent function arguments.
1125   * @returns { Promise<unknown> }
1126   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1127   * 1.Mandatory parameters are left unspecified;
1128   * 2.Incorrect parameter types;
1129   * 3.Parameter verification failed.
1130   * @throws { BusinessError } 10200003 - Worker initialization failed.
1131   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1132   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1133   * @syscap SystemCapability.Utils.Lang
1134   * @crossplatform
1135   * @since 10
1136   */
1137  /**
1138   * Execute a concurrent function.
1139   *
1140   * @param { Function } func - func func Concurrent function want to execute.
1141   * @param { Object[] } args - args args The concurrent function arguments.
1142   * @returns { Promise<Object> }
1143   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1144   * 1.Mandatory parameters are left unspecified;
1145   * 2.Incorrect parameter types;
1146   * 3.Parameter verification failed.
1147   * @throws { BusinessError } 10200003 - Worker initialization failed.
1148   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1149   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1150   * @syscap SystemCapability.Utils.Lang
1151   * @crossplatform
1152   * @atomicservice
1153   * @since 11
1154   */
1155  /**
1156   * Execute a concurrent function.
1157   *
1158   * @param { Function } func - func func Concurrent function want to execute.
1159   * @param { Object[] } args - args args The concurrent function arguments.
1160   * @returns { Promise<Object> }
1161   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1162   * 1.Mandatory parameters are left unspecified;
1163   * 2.Incorrect parameter types;
1164   * 3.Parameter verification failed.
1165   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1166   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1167   * @syscap SystemCapability.Utils.Lang
1168   * @crossplatform
1169   * @atomicservice
1170   * @since 12
1171   */
1172  function execute(func: Function, ...args: Object[]): Promise<Object>;
1173
1174  /**
1175   * Execute a concurrent function with generics.
1176   *
1177   * @param { (...args: A) => R | Promise<R> } func - Concurrent function want to execute.
1178   * @param { A } args - The concurrent function arguments.
1179   * @returns { Promise<R> }
1180   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
1181   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1182   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1183   * @syscap SystemCapability.Utils.Lang
1184   * @atomicservice
1185   * @since 13
1186   */
1187  function execute<A extends Array<Object>, R>(func: (...args: A) => R | Promise<R>, ...args: A): Promise<R>;
1188
1189  /**
1190   * Execute a concurrent task.
1191   *
1192   * @param { Task } task - task task The task want to execute.
1193   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
1194   * @returns { Promise<unknown> }
1195   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1196   * 1.Mandatory parameters are left unspecified;
1197   * 2.Incorrect parameter types;
1198   * 3.Parameter verification failed.
1199   * @throws { BusinessError } 10200003 - Worker initialization failed.
1200   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1201   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1202   * @syscap SystemCapability.Utils.Lang
1203   * @since 9
1204   */
1205  /**
1206   * Execute a concurrent task.
1207   *
1208   * @param { Task } task - task task The task want to execute.
1209   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
1210   * @returns { Promise<unknown> }
1211   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1212   * 1.Mandatory parameters are left unspecified;
1213   * 2.Incorrect parameter types;
1214   * 3.Parameter verification failed.
1215   * @throws { BusinessError } 10200003 - Worker initialization failed.
1216   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1217   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1218   * @syscap SystemCapability.Utils.Lang
1219   * @crossplatform
1220   * @since 10
1221   */
1222  /**
1223   * Execute a concurrent task.
1224   *
1225   * @param { Task } task - task task The task want to execute.
1226   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
1227   * @returns { Promise<Object> }
1228   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1229   * 1.Mandatory parameters are left unspecified;
1230   * 2.Incorrect parameter types;
1231   * 3.Parameter verification failed.
1232   * @throws { BusinessError } 10200003 - Worker initialization failed.
1233   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1234   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1235   * @syscap SystemCapability.Utils.Lang
1236   * @crossplatform
1237   * @atomicservice
1238   * @since 11
1239   */
1240  /**
1241   * Execute a concurrent task.
1242   *
1243   * @param { Task } task - The task want to execute.
1244   * @param { Priority } [priority] - Task priority, MEDIUM is default.
1245   * @returns { Promise<Object> }
1246   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1247   * <br>1. Mandatory parameters are left unspecified;
1248   * <br>2. Incorrect parameter types;
1249   * <br>3. Parameter verification failed.
1250   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1251   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1252   * @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
1253   * @syscap SystemCapability.Utils.Lang
1254   * @crossplatform
1255   * @atomicservice
1256   * @since 12
1257   */
1258  function execute(task: Task, priority?: Priority): Promise<Object>;
1259
1260  /**
1261   * Execute a concurrent task with generics.
1262   *
1263   * @param { GenericsTask<A, R> } task - The task want to execute.
1264   * @param { Priority } [priority] - Task priority, MEDIUM is default.
1265   * @returns { Promise<R> }
1266   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
1267   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1268   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1269   * @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
1270   * @syscap SystemCapability.Utils.Lang
1271   * @atomicservice
1272   * @since 13
1273   */
1274  function execute<A extends Array<Object>, R>(task: GenericsTask<A, R>, priority?: Priority): Promise<R>;
1275
1276  /**
1277   * Execute a concurrent task group.
1278   *
1279   * @param { TaskGroup } group - group group The task group want to execute.
1280   * @param { Priority } [priority] - priority priority Task group priority, MEDIUM is default.
1281   * @returns { Promise<unknown[]> }
1282   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1283   * 1.Mandatory parameters are left unspecified;
1284   * 2.Incorrect parameter types;
1285   * 3.Parameter verification failed.
1286   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1287   * @syscap SystemCapability.Utils.Lang
1288   * @crossplatform
1289   * @since 10
1290   */
1291  /**
1292   * Execute a concurrent task group.
1293   *
1294   * @param { TaskGroup } group - group group The task group want to execute.
1295   * @param { Priority } [priority] - priority priority Task group priority, MEDIUM is default.
1296   * @returns { Promise<Object[]> }
1297   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1298   * 1.Mandatory parameters are left unspecified;
1299   * 2.Incorrect parameter types;
1300   * 3.Parameter verification failed.
1301   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1302   * @syscap SystemCapability.Utils.Lang
1303   * @crossplatform
1304   * @atomicservice
1305   * @since 11
1306   */
1307  function execute(group: TaskGroup, priority?: Priority): Promise<Object[]>;
1308
1309  /**
1310   * Execute a concurrent task after the specified time.
1311   *
1312   * @param { number } delayTime - delayTime delayTime The time want to delay.
1313   * @param { Task } task - task task The task want to execute.
1314   * @param { Priority } [priority] - priority priority Task priority, MEDIUM is default.
1315   * @returns { Promise<Object> }
1316   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1317   * 1.Mandatory parameters are left unspecified;
1318   * 2.Incorrect parameter types;
1319   * 3.Parameter verification failed.
1320   * @throws { BusinessError } 10200028 - The delayTime is less than zero.
1321   * @syscap SystemCapability.Utils.Lang
1322   * @crossplatform
1323   * @atomicservice
1324   * @since 11
1325   */
1326  /**
1327   * Execute a concurrent task after the specified time.
1328   *
1329   * @param { number } delayTime - The time want to delay.
1330   * @param { Task } task - The task want to execute.
1331   * @param { Priority } [priority] - Task priority, MEDIUM is default.
1332   * @returns { Promise<Object> }
1333   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1334   * <br>1. Mandatory parameters are left unspecified;
1335   * <br>2. Incorrect parameter types;
1336   * <br>3. Parameter verification failed.
1337   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1338   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1339   * @throws { BusinessError } 10200028 - The delayTime is less than zero.
1340   * @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
1341   * @syscap SystemCapability.Utils.Lang
1342   * @crossplatform
1343   * @atomicservice
1344   * @since 12
1345   */
1346  function executeDelayed(delayTime: number, task: Task, priority?: Priority): Promise<Object>;
1347
1348  /**
1349   * Execute a concurrent task with generics after the specified time.
1350   *
1351   * @param { number } delayTime - The time want to delay.
1352   * @param { GenericsTask<A, R> } task - The task want to execute.
1353   * @param { Priority } [priority] - Task priority, MEDIUM is default.
1354   * @returns { Promise<R> }
1355   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
1356   * @throws { BusinessError } 10200028 - The delayTime is less than zero.
1357   * @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
1358   * @syscap SystemCapability.Utils.Lang
1359   * @atomicservice
1360   * @since 13
1361   */
1362  function executeDelayed<A extends Array<Object>, R>(delayTime: number, task: GenericsTask<A, R>, priority?: Priority): Promise<R>;
1363
1364  /**
1365   * Execute a concurrent task periodically.
1366   *
1367   * @param { number } period - The period in milliseconds for executing task.
1368   * @param { Task } task - The task want to execute.
1369   * @param { Priority } [priority] - Task priority, MEDIUM is default.
1370   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1371   * <br>1. Mandatory parameters are left unspecified;
1372   * <br>2. Incorrect parameter types;
1373   * <br>3. Parameter verification failed.
1374   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1375   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1376   * @throws { BusinessError } 10200028 - The period is less than zero.
1377   * @throws { BusinessError } 10200050 - The concurrent task has been executed and cannot be executed periodically.
1378   * @syscap SystemCapability.Utils.Lang
1379   * @crossplatform
1380   * @atomicservice
1381   * @since 12
1382   */
1383  function executePeriodically(period: number, task: Task, priority?: Priority): void;
1384
1385  /**
1386   * Execute a concurrent task with generics periodically.
1387   *
1388   * @param { number } period - The period in milliseconds for executing task.
1389   * @param { GenericsTask<A, R> } task - The task want to execute.
1390   * @param { Priority } [priority] - Task priority, MEDIUM is default.
1391   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
1392   * @throws { BusinessError } 10200006 - An exception occurred during serialization.
1393   * @throws { BusinessError } 10200014 - The function is not marked as concurrent.
1394   * @throws { BusinessError } 10200028 - The period is less than zero.
1395   * @throws { BusinessError } 10200050 - The concurrent task has been executed and cannot be executed periodically.
1396   * @syscap SystemCapability.Utils.Lang
1397   * @atomicservice
1398   * @since 13
1399   */
1400  function executePeriodically<A extends Array<Object>, R>(period: number, task: GenericsTask<A, R>, priority?: Priority): void;
1401
1402  /**
1403   * Cancel a concurrent task.
1404   *
1405   * @param { Task } task - task task The task want to cancel.
1406   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1407   * 1.Mandatory parameters are left unspecified;
1408   * 2.Incorrect parameter types;
1409   * 3.Parameter verification failed.
1410   * @throws { BusinessError } 10200015 - The task to cancel does not exist.
1411   * @throws { BusinessError } 10200016 - The task to cancel is being executed.
1412   * @syscap SystemCapability.Utils.Lang
1413   * @since 9
1414   */
1415  /**
1416   * Cancel a concurrent task.
1417   *
1418   * @param { Task } task - task task The task want to cancel.
1419   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1420   * 1.Mandatory parameters are left unspecified;
1421   * 2.Incorrect parameter types;
1422   * 3.Parameter verification failed.
1423   * @throws { BusinessError } 10200015 - The task to cancel does not exist.
1424   * @syscap SystemCapability.Utils.Lang
1425   * @crossplatform
1426   * @since 10
1427   */
1428  /**
1429   * Cancel a concurrent task.
1430   *
1431   * @param { Task } task - task task The task want to cancel.
1432   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1433   * 1.Mandatory parameters are left unspecified;
1434   * 2.Incorrect parameter types;
1435   * 3.Parameter verification failed.
1436   * @throws { BusinessError } 10200015 - The task to cancel does not exist.
1437   * @syscap SystemCapability.Utils.Lang
1438   * @crossplatform
1439   * @atomicservice
1440   * @since 11
1441   */
1442  function cancel(task: Task): void;
1443
1444  /**
1445   * Cancel a concurrent task group.
1446   *
1447   * @param { TaskGroup } group - group group The task group want to cancel.
1448   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1449   * 1.Mandatory parameters are left unspecified;
1450   * 2.Incorrect parameter types;
1451   * 3.Parameter verification failed.
1452   * @throws { BusinessError } 10200018 - The task group to cancel does not exist.
1453   * @syscap SystemCapability.Utils.Lang
1454   * @crossplatform
1455   * @since 10
1456   */
1457  /**
1458   * Cancel a concurrent task group.
1459   *
1460   * @param { TaskGroup } group - group group The task group want to cancel.
1461   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1462   * 1.Mandatory parameters are left unspecified;
1463   * 2.Incorrect parameter types;
1464   * 3.Parameter verification failed.
1465   * @throws { BusinessError } 10200018 - The task group to cancel does not exist.
1466   * @syscap SystemCapability.Utils.Lang
1467   * @crossplatform
1468   * @atomicservice
1469   * @since 11
1470   */
1471  function cancel(group: TaskGroup): void;
1472
1473  /**
1474   * Get task pool internal information.
1475   *
1476   * @returns { TaskPoolInfo }
1477   * @syscap SystemCapability.Utils.Lang
1478   * @crossplatform
1479   * @since 10
1480   */
1481  /**
1482   * Get task pool internal information.
1483   *
1484   * @returns { TaskPoolInfo }
1485   * @syscap SystemCapability.Utils.Lang
1486   * @crossplatform
1487   * @atomicservice
1488   * @since 11
1489   */
1490  function getTaskPoolInfo(): TaskPoolInfo;
1491
1492  /**
1493   * Terminate a long task.
1494   *
1495   * @param { LongTask } longTask - The long task want to terminate.
1496   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1497   * 1.Mandatory parameters are left unspecified;
1498   * 2.Incorrect parameter types;
1499   * 3.Parameter verification failed.
1500   * @syscap SystemCapability.Utils.Lang
1501   * @crossplatform
1502   * @atomicservice
1503   * @since 12
1504   */
1505  function terminateTask(longTask: LongTask): void;
1506
1507  /**
1508   * Check if the function is a concurrent function.
1509   *
1510   * @param { Function } func - The function name to check.
1511   * @returns { boolean } Returns {@code true} if it is a concurrent function; returns {@code false} otherwise.
1512   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1513   * 1.Mandatory parameters are left unspecified;
1514   * 2.Incorrect parameter types;
1515   * 3.Parameter verification failed.
1516   * @syscap SystemCapability.Utils.Lang
1517   * @crossplatform
1518   * @atomicservice
1519   * @since 12
1520   */
1521  function isConcurrent(func: Function): boolean;
1522}
1523
1524export default taskpool;
1525