Skip to content

Commit 82889f7

Browse files
committed
rollup merge of #23902: freebroccolo/master
2 parents 3053288 + 9ba7974 commit 82889f7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/doc/trpl/concurrency.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,15 @@ it returns an `Result<T, E>`, and because this is just an example, we `unwrap()`
280280
it to get a reference to the data. Real code would have more robust error handling
281281
here. We're then free to mutate it, since we have the lock.
282282

283-
This timer bit is a bit awkward, however. We have picked a reasonable amount of
284-
time to wait, but it's entirely possible that we've picked too high, and that
285-
we could be taking less time. It's also possible that we've picked too low,
286-
and that we aren't actually finishing this computation.
287-
288-
Rust's standard library provides a few more mechanisms for two threads to
289-
synchronize with each other. Let's talk about one: channels.
283+
Lastly, while the threads are running, we wait on a short timer. But
284+
this is not ideal: we may have picked a reasonable amount of time to
285+
wait but it's more likely we'll either be waiting longer than
286+
necessary or not long enough, depending on just how much time the
287+
threads actually take to finish computing when the program runs.
288+
289+
A more precise alternative to the timer would be to use one of the
290+
mechanisms provided by the Rust standard library for synchronizing
291+
threads with each other. Let's talk about one of them: channels.
290292

291293
## Channels
292294

0 commit comments

Comments
 (0)