15 ms·
In this specific case yes, but so is the await await as shown at https://youtu.be/4OCUEgSNIAY?t=3545 https://youtu.be/4OCUEgSNIAY?t=3545 in your linked talk. T
by jerven 11y ago
In this specific case yes, but so is the await await as shown at https://youtu.be/4OCUEgSNIAY?t=3545 https://youtu.be/4OCUEgSNIAY?t=3545 in your linked talk.
The nice thing is that join is recursive in the quicksort example and that means its equivalent to the await await syntax in practical terms. Which also means when both are finished it will return.
let mid = partition(v);
let (lo, hi) = v.split_at_mut(mid);
Future:of(|| quick_sort::<J,T>(lo)).await(),
Future:of(|| quick_sort::<J,T>(hi)).await());
Is exactly the same in parallelism as this
let mid = partition(v);
let (lo, hi) = v.split_at_mut(mid);
J::join(|| quick_sort::<J,T>(lo),
|| quick_sort::<J,T>(hi));
Except that join gives better scheduling due to work stealing which will avoid unbalanced cpu usage.
My Rust is non existent but conceptually Rayon is similar to java9 parallel streams which I know well.