I'm trying to make array of workers so I wrote this code.
for(var c=0;c<core;c++){
let worker = new Worker("Html/Worker.js");
worker.postMessage({core:core,W:width,H:height,id:c,px:px,py:py,pz:pz,yaw:yaw,pitch:pitch,D:D,fov:fov});
worker.onmessage=(e)=>{
let gap = this.sH/core*e.data[2];
this.frameBuffer.set(e.data[0],Math.floor(gap)*this.sW*4);
//alert(e.data);
this.depthBuffer.set(e.data[1],Math.floor(gap)*this.sW);
}
this.threads.push(worker);
}
I wonder if it's able to copy worker without multiple initialization (like the code below)
let worker = new Worker("Html/Worker.js");
for(var c=0;c<core;c++){
worker.postMessage({core:core,W:width,H:height,id:c,px:px,py:py,pz:pz,yaw:yaw,pitch:pitch,D:D,fov:fov});
worker.onmessage=(e)=>{
let gap = this.sH/core*e.data[2];
this.frameBuffer.set(e.data[0],Math.floor(gap)*this.sW*4);
this.depthBuffer.set(e.data[1],Math.floor(gap)*this.sW);
}
this.threads.push(worker);
}
does array.push causes deep copying?