Sha256: 6e7030de6d97d1db1c335f676dd2a6348cde2873520df290c4a16bf949c06f00

Contents?: true

Size: 925 Bytes

Versions: 33

Compression:

Stored size: 925 Bytes

Contents

use rayon::prelude::*;
use std::iter::once_with;

const N: usize = 100_000;

#[test]
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn par_bridge_recursion() {
    let pool = rayon::ThreadPoolBuilder::new()
        .num_threads(10)
        .build()
        .unwrap();

    let seq: Vec<_> = (0..N).map(|i| (i, i.to_string())).collect();

    pool.broadcast(|_| {
        let mut par: Vec<_> = (0..N)
            .into_par_iter()
            .flat_map(|i| {
                once_with(move || {
                    // Using rayon within the serial iterator creates an opportunity for
                    // work-stealing to make par_bridge's mutex accidentally recursive.
                    rayon::join(move || i, move || i.to_string())
                })
                .par_bridge()
            })
            .collect();
        par.par_sort_unstable();
        assert_eq!(seq, par);
    });
}

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-28.0.0 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-27.0.0 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-26.0.0 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-25.0.2 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-25.0.1 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-25.0.0 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-24.0.0 ./ext/cargo-vendor/rayon-1.10.0/tests/par_bridge_recursion.rs
wasmtime-23.0.2 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-22.0.0 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-21.0.1 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-20.0.2 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-20.0.0 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-18.0.3 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-17.0.1 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-17.0.0 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-16.0.0 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-15.0.1 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-15.0.0 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs
wasmtime-14.0.4 ./ext/cargo-vendor/rayon-1.8.0/tests/par_bridge_recursion.rs