support worker postMessageWithSharedSendable

Signed-off-by: wangzhaoyong <wangzhaoyong@huawei.com>
Change-Id: I8c234b25d0b8fef4bc4c42357ef5201461f12c2e
This commit is contained in:
wangzhaoyong 2024-03-11 22:02:10 +08:00
parent 3ce05a8a07
commit a8afd6a2ca

35
api/@ohos.worker.d.ts vendored
View File

@ -1092,6 +1092,23 @@ export interface ThreadWorkerGlobalScope extends GlobalScope {
*/
postMessage(messageObject: Object, options?: PostMessageOptions): void;
/**
* Send a message to the host thread from the worker thread.
* If there're sendable objects included in the message, they will be passed through references.
* Non-sendable objects are passed through serialization.
*
* @param { Object } message - Data to be sent to the worker thread.
* @param { ArrayBuffer[] } [transfer] - ArrayBuffer instance that can be transferred.
* @throws { BusinessError } 401 - if the input parameters are invalid.
* @throws { BusinessError } 10200004 - Worker instance is not running.
* @throws { BusinessError } 10200006 - An exception occurred during serialization.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
postMessageWithSharedSendable(message: Object, transfer?: ArrayBuffer[]): void;
/**
* Send a global call on registered globalCallObject on host side and return the result synchronously
*
@ -1428,6 +1445,24 @@ declare namespace worker {
* @since 11
*/
postMessage(message: Object, options?: PostMessageOptions): void;
/**
* Sends a message to the worker thread from the host thread.
* If there're sendable objects included in the message, they will be passed through references.
* Non-sendable objects are passed through serialization.
*
* @param { Object } message - Data to be sent to the worker thread.
* @param { ArrayBuffer[] } [transfer] - ArrayBuffer instance that can be transferred.
* @throws { BusinessError } 401 - if the input parameters are invalid.
* @throws { BusinessError } 10200004 - Worker instance is not running.
* @throws { BusinessError } 10200006 - An exception occurred during serialization.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
postMessageWithSharedSendable(message: Object, transfer?: ArrayBuffer[]): void;
/**
* Adds an event listener to the worker.
*