File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -674,9 +674,13 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
674
674
675
675
Finally, inside of our ` map() ` /` collect() ` loop, we call ` table.clone() ` . The
676
676
` clone() ` method on ` Arc<T> ` is what bumps up the reference count, and when it
677
- goes out of scope, it decrements the count. You’ll notice we can introduce a
678
- new binding to ` table ` here, and it will shadow the old one. This is often used
679
- so that you don’t need to come up with two unique names.
677
+ goes out of scope, it decrements the count. This is needed so that we know how
678
+ many references to ` table ` exist across our threads. If we didn’t have a count,
679
+ we wouldn’t know how to deallocate it.
680
+
681
+ You’ll notice we can introduce a new binding to ` table ` here, and it will
682
+ shadow the old one. This is often used so that you don’t need to come up with
683
+ two unique names.
680
684
681
685
With this, our program works! Only two philosophers can eat at any one time,
682
686
and so you’ll get some output like this:
You can’t perform that action at this time.
0 commit comments