Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve example in the intro. #21020

Merged
merged 1 commit into from
Jan 16, 2015
Merged

Improve example in the intro. #21020

merged 1 commit into from
Jan 16, 2015

Conversation

steveklabnik
Copy link
Member

Thank you @bluss for the suggested implementation.

Fixes #20844

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

ownership of any data it uses; we'll have more on the significance of
this shortly.) This closure is executed in a new thread created by
`spawn`.
This program creates ten threads, who all print `Hello, world!`. The `scoped`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/who/which/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, my closures are people 😉

@steveklabnik
Copy link
Member Author

Addressed both nits.

Thank you @bluss for the suggested implementation.

Fixes rust-lang#20844
bors added a commit that referenced this pull request Jan 14, 2015
Improve example in the intro.

Reviewed-by: alexcrichton
bors added a commit that referenced this pull request Jan 14, 2015
Improve example in the intro.

Reviewed-by: alexcrichton
bors added a commit that referenced this pull request Jan 15, 2015
Improve example in the intro.

Reviewed-by: alexcrichton
});
}
})
}).collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Join guards are collected in this example to show explicitly how the things work, right? The code will behave in exactly the same way if we would just leave them out. Am I correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if you don't collect, the map won't do anything, as it's lazy. If you switch to a for, each guard drops out of scope on each iteration, so they end up executing serially anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, got it!

bors added a commit that referenced this pull request Jan 15, 2015
Improve example in the intro.

Reviewed-by: alexcrichton
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 15, 2015
Thank you @bluss for the suggested implementation.

Fixes rust-lang#20844
@bors bors merged commit e485d29 into rust-lang:master Jan 16, 2015
@steveklabnik steveklabnik deleted the gh20844 branch October 25, 2017 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The example in the concurrency guide is incorrect
7 participants