/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit ArkTS
*/
/**
* JS cross-thread task executor.
*
* @namespace taskpool
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* JS cross-thread task executor.
*
* @namespace taskpool
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* JS cross-thread task executor.
*
* @namespace taskpool
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
declare namespace taskpool {
/**
* The Priority defines the task priority.
*
* @enum { number } Priority
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* The Priority defines the task priority.
*
* @enum { number } Priority
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Enumerates the priorities available for created tasks.
*
* @enum { number } Priority
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
enum Priority {
/**
* set task priority to high.
*
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* set task priority to high.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* The task has a high priority.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
HIGH = 0,
/**
* set task priority to medium.
*
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* set task priority to medium.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* The task has a medium priority.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
MEDIUM = 1,
/**
* set task priority to low.
*
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* set task priority to low.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* The task has a low priority.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
LOW = 2,
/**
* The task is a background task.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
IDLE = 3
}
/**
* Describes a callback function.
*
* @typedef { function } CallbackFunction
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
type CallbackFunction = () => void;
/**
* Describes a callback function with an error message.
*
* @typedef { function } CallbackFunctionWithError
* @param { Error } e - Error message.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
type CallbackFunctionWithError = (e: Error) => void;
/**
* The Task class provides an interface to create a task.
*
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* The Task class provides an interface to create a task.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Implements a task. Before calling any APIs in Task, you must use constructor to create a Task instance.
* A task can be executed for multiple times, placed in a task group, serial queue, or asynchronous queue for execution,
* or added with dependencies for execution.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
class Task {
/**
* Create a Task instance.
*
* @param { Function } func - func func Concurrent function to execute in taskpool.
* @param { unknown[] } args - args args The concurrent function arguments.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* Create a Task instance.
*
* @param { Function } func - func func Concurrent function to execute in taskpool.
* @param { unknown[] } args - args args The concurrent function arguments.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* A constructor used to create a Task instance.
*
* @param { Function } func - Function to be executed. The function must be decorated using @Concurrent.
* For details about the supported return value types of the function, see Sequenceable Data Types.
* @param { Object[] } args - Arguments of the function. For details about the supported parameter types,
* see Sequenceable Data Types. The default value is undefined.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
constructor(func: Function, ...args: Object[]);
/**
* A constructor used to create a Task instance, with the task name specified.
*
* @param { string } name - Task name.
* @param { Function } func - Function to be executed. The function must be decorated using @Concurrent.
* For details about the supported return value types of the function, see Sequenceable Data Types.
* @param { Object[] } args - Arguments of the function. For details about the supported parameter types,
* see Sequenceable Data Types. The default value is undefined.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
constructor(name: string, func: Function, ...args: Object[]);
/**
* Check current running Task is canceled or not.
*
* @returns { boolean } Returns {@code true} if current running task is canceled; returns {@code false} otherwise.
* @static
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Checks whether the running task is canceled. Before using this API, you must create a Task instance.
* isCanceled must be used together with taskpool.cancel. If cancel is not called, isCanceled returns false by default.
*
* @returns { boolean } Returns {@code true} if current running task is canceled; returns {@code false} otherwise.
* @static
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
static isCanceled(): boolean;
/**
* Sends data to the host thread and triggers the registered callback. Before using this API, you must create a Task instance.
* NOTE:
* 1.The API is called in the TaskPool thread.
* 2.Do not use this API in a callback function.
* 3.Before calling this API, ensure that the callback function for processing data has been registered in the host thread.
*
* @param { Object[] } args - Data to be used as the input parameter of the registered callback. For details about
* the supported parameter types, see Sequenceable Data Types. The default value is undefined.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200006 - An exception occurred during serialization.
* @throws { BusinessError } 10200022 - The function is not called in the TaskPool thread.
* @throws { BusinessError } 10200023 - The function is not called in the concurrent function.
* @throws { BusinessError } 10200024 - The callback is not registered on the host side.
* @static
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
static sendData(...args: Object[]): void;
/**
* Set transfer list for this task.
*
* @param { ArrayBuffer[] } [transfer] - transfer Transfer list of this task, empty array is default.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Sets the task transfer list. Before using this API, you must create a Task instance. If this API is not called,
* the ArrayBuffer in the data is transferred by default.
* NOTE:
* This API is used to set the task transfer list in the form of ArrayBuffer in the task pool.
* The ArrayBuffer instance does not copy the content in the task to the worker thread during transfer.
* Instead, it transfers the buffer control right to the worker thread. After the transfer, the ArrayBuffer instance
* becomes invalid. An empty ArrayBuffer will not be transferred.
*
* @param { ArrayBuffer[] } [transfer] - ArrayBuffer instance holding the objects to transfer. The default value is an empty array.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
* @throws { BusinessError } 10200029 - An ArrayBuffer cannot be set as both a transfer list and a clone list.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
setTransferList(transfer?: ArrayBuffer[]): void;
/**
* Sets the task clone list. Before using this API, you must create a Task instance.
* NOTE:
* This API must be used together with the @Sendable decorator. Otherwise, an exception is thrown.
*
* @param { Object[] | ArrayBuffer[] } cloneList - The type of the passed-in array must be sendable data types or ArrayBuffer.
* All Sendable class instances or ArrayBuffer objects passed in to cloneList are transferred in copy mode between threads.
* This means that any modification to the destination objects does not affect the original objects.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200029 - An ArrayBuffer cannot be set as both a transfer list and a clone list.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
setCloneList(cloneList: Object[] | ArrayBuffer[]): void;
/**
* Registers a callback for a task to receive and process data from the worker thread. Before using this API, you must create a Task instance.
* NOTE:
* If multiple callbacks are registered for the same task, only the last registration takes effect.
*
* @param { Function } [callback] - Callback function for processing the data received. The data sent to the host
* thread is transferred to the callback as an input parameter. If no value is passed in, all the registered callbacks are canceled.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
onReceiveData(callback?: Function): void;
/**
* Add dependencies on the task array for this task.
*
* @param { Task[] } tasks - tasks tasks An array of dependent tasks.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200026 - There is a circular dependency.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
/**
* Add dependencies on the task array for this task.
*
* @param { Task[] } tasks - An array of dependent tasks.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 10200026 - There is a circular dependency.
* @throws { BusinessError } 10200052 - The periodic task cannot have a dependency.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
/**
* Adds dependent tasks for this task. Before using this API, you must create a Task instance.
* The task and its dependent tasks cannot be a task in a task group, serial queue, or asynchronous queue,
* a task that has been executed, or a periodic task. A task with a dependency relationship (a task that depends
* on another task or a task that is depended on) cannot be executed multiple times.
*
* @param { Task[] } tasks - Array of tasks on which the current task depends. The default value is undefined.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 10200026 - There is a circular dependency.
* @throws { BusinessError } 10200052 - The periodic task cannot have a dependency.
* @throws { BusinessError } 10200056 - The task has been executed by the AsyncRunner.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 18
*/
addDependency(...tasks: Task[]): void;
/**
* Remove dependencies on the task array for this task.
*
* @param { Task[] } tasks - tasks tasks An array of dependent tasks.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200027 - The dependency does not exist.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
/**
* Remove dependencies on the task array for this task.
*
* @param { Task[] } tasks - An array of dependent tasks.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 10200027 - The dependency does not exist.
* @throws { BusinessError } 10200052 - The periodic task cannot have a dependency.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
/**
* Removes dependent tasks for this task. Before using this API, you must create a Task instance.
*
* @param { Task[] } tasks - Array of tasks on which the current task depends. The default value is undefined.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 10200027 - The dependency does not exist.
* @throws { BusinessError } 10200052 - The periodic task cannot have a dependency.
* @throws { BusinessError } 10200056 - The task has been executed by the AsyncRunner.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 18
*/
removeDependency(...tasks: Task[]): void;
/**
* Register a callback function and call it when a task is enqueued.
* The registration must be carried out before the task is executed. Otherwise, an exception is thrown.
*
* @param { CallbackFunction } [callback] - Callback function to register.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
onEnqueued(callback: CallbackFunction): void;
/**
* Register a callback function and call it when the execution of a task starts.
* The registration must be carried out before the task is executed. Otherwise, an exception is thrown.
*
* @param { CallbackFunction } [callback] - Callback function to register.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
onStartExecution(callback: CallbackFunction): void;
/**
* Register a callback function and call it when a task fails to be executed.
* The registration must be carried out before the task is executed. Otherwise, an exception is thrown.
*
* @param { CallbackFunctionWithError } [callback] - Callback function to register.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
onExecutionFailed(callback: CallbackFunctionWithError): void;
/**
* Register a callback function and call it when a task is executed successfully.
* The registration must be carried out before the task is executed. Otherwise, an exception is thrown.
*
* @param { CallbackFunction } [callback] - Callback function to register.
* @throws { BusinessError } 401 - The input parameters are invalid.
* @throws { BusinessError } 10200034 - The executed task does not support the registration of listeners.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
onExecutionSucceeded(callback: CallbackFunction): void;
/**
* Checks whether the task is complete.
*
* @returns { boolean } Returns {@code true} if the task has been completed; returns {@code false} otherwise.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
isDone(): boolean;
/**
* Concurrent function to execute in taskpool.
*
* @type { Function }
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* Concurrent function to execute in taskpool.
*
* @type { Function }
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Function to be passed in during task creation. For details about the supported return value types of the function, see Sequenceable Data Types.
*
* @type { Function }
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
function: Function;
/**
* The concurrent function arguments.
*
* @syscap SystemCapability.Utils.Lang
* @since 9
*/
/**
* The concurrent function arguments.
*
* @type { ?unknown[] }
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Arguments of the function. For details about the supported parameter types, see Sequenceable Data Types.
*
* @type { ?Object[] }
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
arguments?: Object[];
/**
* Name of the task specified when the task is created.
*
* @type { string }
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
name: string;
/**
* Task ID.
*
* @type { number }
* @default 0
* @syscap SystemCapability.Utils.Lang
* @atomicservice
* @since 18
*/
taskId: number;
/**
* Total execution time of the task. in ms.
*
* @type { number }
* @default 0
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
totalDuration: number;
/**
* Asynchronous I/O time of the task. in ms.
*
* @type { number }
* @default 0
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
ioDuration: number;
/**
* CPU time of the task. in ms.
*
* @type { number }
* @default 0
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
cpuDuration: number;
}
/**
* The TaskGroup class provides an interface to create a task group.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Implements a task group, in which tasks are associated with each other and all tasks are executed at a time.
* If all the tasks are executed normally, an array of task results is returned asynchronously, and the sequence of
* elements in the array is the same as the sequence of tasks added by calling addTask. If any task fails,
* the corresponding exception is thrown. If multiple tasks in the task group fail, the exception of the first failed
* task is thrown. A task group can be executed for multiple times, but no task can be added after the task group is executed.
* Before calling any APIs in TaskGroup, you must use constructor to create a TaskGroup instance.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
class TaskGroup {
/**
* Create a TaskGroup instance.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Constructor used to create a TaskGroup instance.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
constructor();
/**
* A constructor used to create a TaskGroup instance, with the task group name specified.
*
* @param { string } name - Task group name.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
constructor(name: string);
/**
* Add a Concurrent function into task group.
*
* @param { Function } func - func func Concurrent function to add in task group.
* @param { unknown[] } args - args args The concurrent function arguments.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Adds the function to be executed to this task group. Before using this API, you must create a TaskGroup instance.
*
* @param { Function } func - Function to be executed. The function must be decorated using @Concurrent.
* For details about the supported return value types of the function, see Sequenceable Data Types.
* @param { Object[] } args - Arguments of the function. For details about the supported parameter types,
* see Sequenceable Data Types. The default value is undefined.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
addTask(func: Function, ...args: Object[]): void;
/**
* Add a Task into TaskGroup.
*
* @param { Task } task - task task The task want to add in task group.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @since 10
*/
/**
* Add a Task into TaskGroup.
*
* @param { Task } task - task task The task want to add in task group.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types;
* 3.Parameter verification failed.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
/**
* Add a Task into TaskGroup.
*
* @param { Task } task - The task want to add in task group.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
/**
* Adds a created task to this task group. Before using this API, you must create a TaskGroup instance.
* Tasks in another task group, serial queue, or asynchronous queue, dependent tasks, continuous tasks,
* tasks that have been executed, and periodic tasks cannot be added to the task group.
*
* @param { Task } task - Task to be added to the task group.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 10200014 - The function is not marked as concurrent.
* @throws { BusinessError } 10200051 - The periodic task cannot be executed again.
* @throws { BusinessError } 10200057 - The task cannot be executed by two APIs.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 18
*/
addTask(task: Task): void;
/**
* Name of the task group specified when the task group is created.
*
* @type { string }
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
name: string;
}
/**
* Implements a serial queue, in which all tasks are executed in sequence. Before calling any APIs in SequenceRunner,
* you must use constructor to create a SequenceRunner instance.
*
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
class SequenceRunner {
/**
* A constructor used to create a SequenceRunner instance.
*
* @param { Priority } priority - Priority of the task. The default value is taskpool.Priority.MEDIUM.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Incorrect parameter types;
* 2.Parameter verification failed.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 11
*/
constructor(priority?: Priority);
/**
* A constructor used to create a SequenceRunner instance. This instance represents a global serial queue.
* If the passed-in name is the same as an existing name, the same serial queue is returned.
* NOTE:
* 1.The bottom layer uses the singleton mode to ensure that the same instance is obtained when a serial queue with the same name is created.
* 2.The priority of a serial queue cannot be modified.
*
* @param { string } name - Name of a serial queue.
* @param { Priority } priority - Priority of the task. The default value is taskpool.Priority.MEDIUM.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.
* 2. Incorrect parameter types. 3.Parameter verification failed.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor(name: string, priority?: Priority);
/**
* Execute a concurrent function.
*
* @param { Task } task - The task want to execute.
* @returns { Promise