[][src]Macro join::try_join_spawn

macro_rules! try_join_spawn {
    #[proc_macro_hack(support_nested)] => { ... };
}

Use to spawn ::std::thread per each step of each branch. It transposes tuple of Results/Options into Result/Option of tuple or single Result/Option in case of 1 branch.

Example:

extern crate join;

use join::try_join_spawn;

let product = try_join_spawn! {
    Ok::<_,()>(2) |> |v| v + 2 ?? |_| {
        println!("Hello from parallel world!");
        ::std::thread::sleep(::std::time::Duration::from_secs(1));
        println!("I'm done.");
    },
    Ok::<_,()>(3) ?? |_| {
        println!("Hello from parallel world again!");
        ::std::thread::sleep(::std::time::Duration::from_secs(2));
        println!("Me too.");
    },
    Ok::<_,()>(4),
    map => |a, b, c| a * b * c
}.unwrap();

assert_eq!(product, 48);