Structured cloning - which thread does the clone?

268 Views Asked by At

I have some work being done on a WebWorker. When I post an object back to my GUI thread, the Javascript engine uses the structured cloning algorithm to clone the object with the GUI thread receiving a cloned object.

My question is, where is the cloning work being done, on the sender (WebWorker), receiver (GUI thread), both, or have I got completely the wrong end of the stick?

1

There are 1 best solutions below

2
On

You can only send message width cloned data. And as there is no communication between threads except postMessages, there is no way receiver can perform structured cloning. SO cloning work is implemented on thread that sends a message.