rayon_join/lib.rs
1//! A simple macro to call `rayon::join` with more than 2 arguments.
2#[macro_export]
3/// Executes multiple closures in parallel using `rayon::join`.
4/// ## Usage
5/// You can pass any number of closures:
6/// ```
7/// rayon_join::join!(|| { /* task 1 */ }, || { /* task 2 */ }, || { /* task 3 */ });
8/// ```
9/// You can also pass functions:
10/// ```
11/// fn task1() { /* ... */ }
12/// fn task2() { /* ... */ }
13/// fn task3() { /* ... */ }
14/// rayon_join::join!(task1, task2, task3);
15/// ```
16/// If you need to pass arguments to the functions, use a closure:
17/// ```
18/// fn task_with_arg(x: i32) { /* ... */ }
19/// rayon_join::join!(|| task_with_arg(42), || task_with_arg(7));
20/// ```
21macro_rules! join {
22 ($f1:expr, $f2:expr) => {
23 rayon::join($f1, $f2)
24 };
25 ($f1:expr, $f2:expr, $($rest:expr),+) => {
26 rayon::join($f1, || join!($f2, $($rest),+))
27 };
28
29}