parent
7b0f2af27f
commit
e12c420522
@ -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. You’ll notice we can introduce a
|
||||
new binding to `table` here, and it will shadow the old one. This is often used
|
||||
so that you don’t 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 didn’t have a count,
|
||||
we wouldn’t know how to deallocate it.
|
||||
|
||||
You’ll notice we can introduce a new binding to `table` here, and it will
|
||||
shadow the old one. This is often used so that you don’t need to come up with
|
||||
two unique names.
|
||||
|
||||
With this, our program works! Only two philosophers can eat at any one time,
|
||||
and so you’ll get some output like this:
|
||||
|
Loading…
x
Reference in New Issue
Block a user