3 ms·
How it is the zero-copy ArrayBuffer transfer function implemented?
by siscia 5y ago
How it is the zero-copy ArrayBuffer transfer function implemented?
- lucacasonato 5y agoArrayBuffers are just views on underlying memory owned by the thread a V8 isolate is running on. (Each worker runs on a separate thread, each with its own V8 isolate). When we transfer an ArrayBuffer, we detach the underlying memory from the isolate in the sending thread, and move ownership of the memory area to the receiving thread, where a new JS ArrayBuffer object is created that points to that memory area. TLDR: The memory is never moved, the pointers to it are just detached from one isolate, and instead passed to another.
- csmpltn 5y agoHats off to you, helping Javascript programmers break out of the matrix ;)