1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
use crate::prelude::*;
use rayon;

// TODO: Have a way to not use rayon when the operation is considered 'trivial'
#[inline(always)]
pub fn parallel<A: Send, B: Send>(
    a: impl FnOnce() -> A + Send,
    b: impl FnOnce() -> B + Send,
    options: &impl DecodeOptions) -> (A, B) {
    if options.parallel() {
        rayon::join(a, b)
    } else {
        (a(), b())
    }
}