scheduleTask

suspend fun scheduleTask(parameters: Any, transferableObjects: ReadonlyArray<Any>? = definedExternally): Any?(source)

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.

const taskProcessor = new TaskProcessor('myWorkerPath');
const promise = taskProcessor.scheduleTask({
someParameter : true,
another : 'hello'
});
if (!Cesium.defined(promise)) {
// too many active tasks - try again later
} else {
promise.then(function(result) {
// use the result of the task
});
}

Return

Either a promise that will resolve to the result when available, or undefined if there are too many active tasks,

Parameters

parameters

Any input data that will be posted to the worker.

transferableObjects

An array of objects contained in parameters that should be transferred to the worker instead of copied.

See also