Skip to content
Permalink
Browse files

Run the first block in a parallel! macro directly in the scope which …

…guarantees that it will run immediately
  • Loading branch information...
Zoxc committed Feb 23, 2019
1 parent d5bb71c commit d2923e5a77b318300c9d35d63d594125b8b9a43f
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/librustc_data_structures/sync.rs
@@ -280,21 +280,22 @@ cfg_if! {

#[macro_export]
macro_rules! parallel {
(impl [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
parallel!(impl [$block, $($c,)*] [$($rest),*])
(impl $fblock:tt [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
parallel!(impl $fblock [$block, $($c,)*] [$($rest),*])
};
(impl [$($blocks:tt,)*] []) => {
(impl $fblock:tt [$($blocks:tt,)*] []) => {
::rustc_data_structures::sync::scope(|s| {
$(
s.spawn(|_| $blocks);
)*
$fblock;
})
};
($($blocks:tt),*) => {
($fblock:tt, $($blocks:tt),*) => {
// Reverse the order of the blocks since Rayon executes them in reverse order
// when using a single thread. This ensures the execution order matches that
// of a single threaded rustc
parallel!(impl [] [$($blocks),*]);
parallel!(impl $fblock [] [$($blocks),*]);
};
}

0 comments on commit d2923e5

Please sign in to comment.
You can’t perform that action at this time.