en

concurrent Module

Function

atomic

将对象包装为原子对象
ESM-import allowed.
return type: void
parameters:

name type comment
obj any

getAtomicTimeout

获取原子对象等待最长时间,单位ms,默认30000
ESM-import allowed.
return type: number

setAtomicTimeout

设置原子对象等待最长时间,单位ms,默认30000
ESM-import allowed.
return type: void
parameters:

name type comment
timeout number

Class

Worker

ESM-import allowed.

Member

jsWorker

Belongs to: Worker
type: any

Method

Constructor

创建一个Worker
Belongs to: Worker
return type: void
parameters:

name type comment
sourcePath string worker源代码路径
startImmediately boolean 是否立即启动worker执行,默认true

start

启动尚未启动的worker
Belongs to: Worker
return type: void

postMessage

向Worker发送信息,返回Worker的onmessage函数的返回值
Belongs to: Worker
return type: any
parameters:

name type comment
values any

postMessageAsync

向Worker发送异步信息,返回一个Promise
Belongs to: Worker
return type: Promise.<any>
parameters:

name type comment
values any

terminate

终结(强制停止)此Worker
Belongs to: Worker
return type: void

Job

ESM-import allowed.

Member

job

Belongs to: Job
type: any

Method

Constructor

创建一个Job
Belongs to: Job
return type: void
parameters:

name type comment
sourcePath string Job源代码路径
startImmediately boolean 是否立即启动job,默认true

work

执行Job的main函数并传入指定参数
Belongs to: Job
return type: Promise.<any>
parameters:

name type comment
args ... any

terminate

终结(强制停止)此Job
Belongs to: Job
return type: void


© PowerNukkitX Dev team