Skip to content

Commit db9a1c1

Browse files
committed
Add some comments
1 parent 7cc7b8f commit db9a1c1

File tree

1 file changed

+7
-1
lines changed
  • src/librustc_data_structures

1 file changed

+7
-1
lines changed

src/librustc_data_structures/sync.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ cfg_if! {
131131
#[macro_export]
132132
macro_rules! parallel {
133133
($($blocks:tt),*) => {
134+
// We catch panics here ensuring that all the blocks execute.
135+
// This makes behavior consistent with the parallel compiler.
134136
let mut panic = None;
135137
$(
136138
if let Err(p) = ::std::panic::catch_unwind(
@@ -158,6 +160,8 @@ cfg_if! {
158160
for_each:
159161
impl Fn(<<T as IntoIterator>::IntoIter as Iterator>::Item) + Sync + Send
160162
) {
163+
// We catch panics here ensuring that all the loop iterations execute.
164+
// This makes behavior consistent with the parallel compiler.
161165
let mut panic = None;
162166
t.into_iter().for_each(|i| {
163167
if let Err(p) = catch_unwind(AssertUnwindSafe(|| for_each(i))) {
@@ -309,6 +313,8 @@ cfg_if! {
309313
use std::thread;
310314
pub use rayon::{join, scope};
311315

316+
/// Runs a list of blocks in parallel. The first block is executed immediately on
317+
/// the current thread. Use that for the longest running block.
312318
#[macro_export]
313319
macro_rules! parallel {
314320
(impl $fblock:tt [$($c:tt,)*] [$block:tt $(, $rest:tt)*]) => {
@@ -323,7 +329,7 @@ cfg_if! {
323329
})
324330
};
325331
($fblock:tt, $($blocks:tt),*) => {
326-
// Reverse the order of the blocks since Rayon executes them in reverse order
332+
// Reverse the order of the later blocks since Rayon executes them in reverse order
327333
// when using a single thread. This ensures the execution order matches that
328334
// of a single threaded rustc
329335
parallel!(impl $fblock [] [$($blocks),*]);

0 commit comments

Comments
 (0)