diff options
| author | Darin Morrison <darinmorrison+git@gmail.com> | 2015-03-31 14:14:04 -0600 |
|---|---|---|
| committer | Darin Morrison <darinmorrison+git@gmail.com> | 2015-03-31 14:17:13 -0600 |
| commit | 9ba7974b357c7f2f69d74c9f8a01e282d7f4da6f (patch) | |
| tree | f4d2b16a709f62259e85bc0c57e4b2501285e3d7 | |
| parent | 80bf31dd514055177b22c3dc66836d39eb5b1648 (diff) | |
| download | rust-9ba7974b357c7f2f69d74c9f8a01e282d7f4da6f.tar.gz rust-9ba7974b357c7f2f69d74c9f8a01e282d7f4da6f.zip | |
book: reword timer bit
| -rw-r--r-- | src/doc/trpl/concurrency.md | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/doc/trpl/concurrency.md b/src/doc/trpl/concurrency.md index 79cb3117c0e..6b814a68542 100644 --- a/src/doc/trpl/concurrency.md +++ b/src/doc/trpl/concurrency.md @@ -280,13 +280,15 @@ it returns an `Result<T, E>`, and because this is just an example, we `unwrap()` it to get a reference to the data. Real code would have more robust error handling here. We're then free to mutate it, since we have the lock. -This timer bit is a bit awkward, however. We have picked a reasonable amount of -time to wait, but it's entirely possible that we've picked too high, and that -we could be taking less time. It's also possible that we've picked too low, -and that we aren't actually finishing this computation. - -Rust's standard library provides a few more mechanisms for two threads to -synchronize with each other. Let's talk about one: channels. +Lastly, while the threads are running, we wait on a short timer. But +this is not ideal: we may have picked a reasonable amount of time to +wait but it's more likely we'll either be waiting longer than +necessary or not long enough, depending on just how much time the +threads actually take to finish computing when the program runs. + +A more precise alternative to the timer would be to use one of the +mechanisms provided by the Rust standard library for synchronizing +threads with each other. Let's talk about one of them: channels. ## Channels |
