3 ms·
>Surely these already exist somewhere? (If I know my JS library world, several dozen times over.) The problem is the access to data. You have to pass data to
by Lerc 9y ago
>Surely these already exist somewhere? (If I know my JS library world, several dozen times over.)
The problem is the access to data. You have to pass data to a Worker. To take the canonical embarrassingly parallel task, ray-tracing, each ray can be executed in parallel but they all refer to a common scene. Passing the scene on a per-ray basis would lose any gains. Passing a scene then doing a batch of rays is only 'slightly parallel'
consider a list of points and you want to make a table showing their relative distances
var distances = list.map(a=>list.map(b=>distance(a,b)));
That's something that has plenty of potential for parallelism, but to do so the function inside the first map also needs be able to see the list. What I really want is something where I can write a piece of code as simple as that where it will run on as many cores as the host device has available.
- CuriousSkeptic 9y agoYou would need immutability (or a static type system) to do that safely though. And I don’t think you can check the closed over objects before the closure is actually scheduled to execute (perhaps if you limit the closure to const references) But, since you can pass a context explicitly to map and friends you might get away with checking that for immutability.