Rewrite the parallel raytracing example with rayon

One of the best parts about concurrency in Rust is using `rayon` and how
easy it makes parallelization of tasks, so it's the ideal example for
parallel Rust on the web! Previously we've been unable to use `rayon`
because there wasn't a way to customize how rayon threads themselves are
spawned, but [that's now being developed for us][rayon]!

This commit uses that PR to rewrite the `raytrace-parallel` example in
this repository. While not a perfect idiomatic representation of using
`rayon` I think this is far more idiomatic than the previous iteration
of `raytrace-parallel`! I'm hoping that we can continue to iterate on
this, but otherwise show it off as a good example of parallel Rust on
the web.

[rayon]: https://github.com/rayon-rs/rayon/pull/636
This commit is contained in:
Alex Crichton
2019-02-28 10:37:53 -08:00
parent f027bb2e09
commit eafc6024cc
6 changed files with 413 additions and 299 deletions

View File

@ -28,5 +28,9 @@ function run(ptr) {
return;
}
lastPtr = null;
wasm_bindgen.child_entry_point(ptr);
try {
wasm_bindgen.child_entry_point(ptr);
} catch (e) {
throw new Error(e.message + "\n\n" + e.stack);
}
}