yanni 的回答展示了如何将一个缓冲区发送(转移所有权)给网络 worker : Using transferable objects from a Web Worker
我如何将多个缓冲区(在一个数组中)发送给网络 worker (不复制)?
最佳答案
这已在其他地方得到解答,但在我最终找到答案之前,谷歌先把我带到这里 here .
您可以将多个缓冲区传递给网络 worker ,而无需使用 Transferable objects 执行复制:
The worker case, the first argument is the data and the second is the list of items that should be transferred. The first argument doesn't have to be an ArrayBuffer by the way. For example, it can be a JSON object:
worker.postMessage(
{data: int8View, moreData: anotherBuffer},
[int8View.buffer, anotherBuffer]
);
关于javascript - 向 Javascript 网络 worker 发送多个数组缓冲区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20042948/