Creating SharedArrayBuffer

So far, we've see how to send data between the main thread and workers. The downside of how we've done this so far is that the data is copied. This means that as the amount of data and number of workers increase, so does the amount of copying that has to be done. Luckily, there is a way to share data between threads with less overhead.

SharedArrayBuffer can be shared between arrays without copying data. In this recipe, we'll see how to create, as well as read and write, data from a SharedArrayBuffer.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.