Typed arrays can be copied or transferred between workers, but it's not possible for multiple workers to work with a buffer in parallel without copies. This document describes two ways to improve this without introducing data races: transferring read-write access to disjoint regions of buffers, and transferring read-only access to shared buffers/regions.
This variant of the API enables fine-grained borrowing and sharing, where a single ArrayBuffer
can have multiple disjoint regions parceled out. This way individual workers can work with their regions at their original indices. This makes the API more amenable to being a compilation target.
Here is an example that demonstrates sharing a read-only segment and multiple read-write segments with four separate workers.