Skip to content

[doc] Fix multi-threading example in dining-philosophers #26990

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

Merged
merged 2 commits into from
Jul 13, 2015

Conversation

rwz
Copy link
Contributor

@rwz rwz commented Jul 12, 2015

The current example does not illustrate threaded behavior imo.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rwz
Copy link
Contributor Author

rwz commented Jul 12, 2015

Oh man, I didn't notice the philosophers names are different.

@rwz rwz changed the title Fix multi-threading example in dining-philosophers [doc] Fix multi-threading example in dining-philosophers Jul 12, 2015
@alexcrichton
Copy link
Member

The current example does actually show off multithreading, it's just not as interleaved as one might expect because you have to lock your fork on the table and if you can't you haven't started eating. The actual scenario where everyone starts eating all at once before anyone has finished is impossible because there aren't enough forks to go around.

Thanks for the PR though!

@rwz
Copy link
Contributor Author

rwz commented Jul 12, 2015

At the point that I've edited we still don't have any locks/forks. This is the example where everyone start at the same time, wait 1 second and then finish, roughly at the same time again. Mutexes (forks) are added in the next step. The output I've fixed reflects what I was actually getting implementing the example.

@alexcrichton
Copy link
Member

Oh oops sorry, missed that part!

@alexcrichton alexcrichton reopened this Jul 12, 2015
@alexcrichton
Copy link
Member

@bors: r+ 49e4583 rollup

@bors
Copy link
Collaborator

bors commented Jul 13, 2015

⌛ Testing commit 49e4583 with merge a16a417...

bors added a commit that referenced this pull request Jul 13, 2015
The current example does not illustrate threaded behavior imo.
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.

4 participants