Rollup merge of #26136 - steveklabnik:gh25597, r=alexcrichton

Fixes #25597
This commit is contained in:
Steve Klabnik 2015-06-09 17:24:44 -04:00
commit b38e9a73d4

View file

@ -674,9 +674,13 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
Finally, inside of our `map()`/`collect()` loop, we call `table.clone()`. The
`clone()` method on `Arc<T>` is what bumps up the reference count, and when it
goes out of scope, it decrements the count. Youll notice we can introduce a
new binding to `table` here, and it will shadow the old one. This is often used
so that you dont need to come up with two unique names.
goes out of scope, it decrements the count. This is needed so that we know how
many references to `table` exist across our threads. If we didnt have a count,
we wouldnt know how to deallocate it.
Youll notice we can introduce a new binding to `table` here, and it will
shadow the old one. This is often used so that you dont need to come up with
two unique names.
With this, our program works! Only two philosophers can eat at any one time,
and so youll get some output like this: