TaskProcessor

external class TaskProcessor(workerPath: String, maximumActiveTasks: Double? = definedExternally)(source)

A wrapper around a web worker that allows scheduling tasks for a given worker, returning results asynchronously via a promise.

The Worker is not constructed until a task is scheduled.

Parameters

workerPath

The Url to the worker. This can either be an absolute path or relative to the Cesium Workers folder.

maximumActiveTasks

The maximum number of active tasks. Once exceeded, scheduleTask will not queue any more tasks, allowing work to be rescheduled in future frames. Default value - Number.POSITIVE_INFINITY

See also

Constructors

Link copied to clipboard
constructor(workerPath: String, maximumActiveTasks: Double? = definedExternally)

Types

Link copied to clipboard

Functions

Link copied to clipboard
fun destroy()

Destroys this object. This will immediately terminate the Worker.

Link copied to clipboard
suspend fun initWebAssemblyModule(options: TaskProcessor.InitWebAssemblyModuleOptions? = definedExternally): Any

Posts a message to a web worker with configuration to initialize loading and compiling a web assembly module asynchronously, as well as an optional fallback JavaScript module to use if Web Assembly is not supported.

Link copied to clipboard

Returns true if this object was destroyed; otherwise, false.

Link copied to clipboard
suspend fun scheduleTask(parameters: Any, transferableObjects: ReadonlyArray<Any>? = definedExternally): Any?

Schedule a task to be processed by the web worker asynchronously. If there are currently more tasks active than the maximum set by the constructor, will immediately return undefined. Otherwise, returns a promise that will resolve to the result posted back by the worker when finished.

Link copied to clipboard
fun scheduleTaskAsync(parameters: Any, transferableObjects: ReadonlyArray<Any>? = definedExternally): Promise<Any>?