createTaskProcessorWorker(workerFunction) → createTaskProcessorWorker~TaskProcessorWorkerFunction
Creates an adapter function to allow a calculation function to operate as a Web Worker,
paired with TaskProcessor, to receive tasks and return results.
Name | Type | Description |
---|---|---|
workerFunction |
createTaskProcessorWorker~WorkerFunction | The calculation function, which takes parameters and returns a result. |
Returns:
A function that adapts the
calculation function to work as a Web Worker onmessage listener with TaskProcessor.
Example:
function doCalculation(parameters, transferableObjects) {
// calculate some result using the inputs in parameters
return result;
}
return Cesium.createTaskProcessorWorker(doCalculation);
// the resulting function is compatible with TaskProcessor
See:
Type Definitions
A Web Worker message event handler function that handles the interaction with TaskProcessor,
specifically, task ID management and posting a response message containing the result.
Name | Type | Description |
---|---|---|
event |
Object | The onmessage event object. |
A function that performs a calculation in a Web Worker.
Name | Type | Description |
---|---|---|
parameters |
Object | Parameters to the calculation. |
transferableObjects |
Array | An array that should be filled with references to objects inside the result that should be transferred back to the main document instead of copied. |
Returns:
The result of the calculation.
Example:
function calculate(parameters, transferableObjects) {
// perform whatever calculation is necessary.
var typedArray = new Float32Array(0);
// typed arrays are transferable
transferableObjects.push(typedArray)
return {
typedArray : typedArray
};
}