From edd1c333c62bfbe72261ba281d1626012c0caf32 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sun, 26 Feb 2017 20:56:56 -0500 Subject: [PATCH] Appease the spellchecker (yay!) --- dictionary.txt | 8 ++++++++ src/ch16-01-threads.md | 4 ++-- src/ch16-03-shared-state.md | 14 +++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/dictionary.txt b/dictionary.txt index 35786ec10..1f5fbdd2b 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -158,7 +158,12 @@ monomorphization Monomorphization monomorphized MoveMessage +mpsc +mutex Mutex +mutexes +Mutexes +MutexGuard namespace namespaced namespaces @@ -174,6 +179,7 @@ null's OCaml offsetof online +OpenGL OptionalFloatingPointNumber OptionalNumber OsStr @@ -197,6 +203,7 @@ RAII randcrate READMEs rect +recv redeclaring Refactoring refactor @@ -249,6 +256,7 @@ Summarizable Supertraits That'd test's +threadsafe Tiếng timeline TODO diff --git a/src/ch16-01-threads.md b/src/ch16-01-threads.md index 7718a9f88..03c302d74 100644 --- a/src/ch16-01-threads.md +++ b/src/ch16-01-threads.md @@ -7,7 +7,7 @@ many processes, and this is what lets multiple programs execute at the same time on your computer. We can take this idea down one level of abstraction: what if your program could -also have independent bits of execution, and allow them to run simultanously? +also have independent bits of execution, and allow them to run simultaneously? This feature is called *threads*. There are a few different ways to implement threads, however. Many operating @@ -120,7 +120,7 @@ fn main() { } ``` -Becuase we access `v` inside the closure, the closure will capture it into its +Because we access `v` inside the closure, the closure will capture it into its environment. And because `thread::spawn` runs this closure in a new thread, we can access `v` inside that new thread. diff --git a/src/ch16-03-shared-state.md b/src/ch16-03-shared-state.md index af8484cc1..6f2e606fb 100644 --- a/src/ch16-03-shared-state.md +++ b/src/ch16-03-shared-state.md @@ -22,10 +22,10 @@ more common concurrency primitives for shared memory: mutexes. A *mutex* is a concurrency primitive for sharing memory. It's short for "mutual exclusion", that is, it only allows one thread to access some data at any given -time. Mutexes have a reputation as being hard to use, becuase there's a lot you +time. Mutexes have a reputation as being hard to use, because there's a lot you have to remember: -1. You have to remember to actually attempt to aquire the lock. +1. You have to remember to actually attempt to acquire the lock. 2. One you're done with the memory that's being guarded by the mutex, you have to remember to unlock the memory. @@ -44,15 +44,15 @@ let mut num = m.lock().unwrap(); ``` Like many types, we create a `Mutex` through a `new` method. To access -the data inside the mutex, we use the `lock` method to aquire the lock. This +the data inside the mutex, we use the `lock` method to acquire the lock. This call will block until we're able to do so. This call can fail, so similar to the last section, we use `unwrap()` for now, rather than better error handling. See Chapter 9 for better tools. -Once we have aquired the lock, we can treat its return value, named `num` in +Once we have acquired the lock, we can treat its return value, named `num` in this case, as a mutable reference to the data inside. This is how the first problem with mutexes is solved; `Mutex` is not an `i32`, and so we _must_ -aquire the lock in order to use this memory. We can't forget; the type system +acquire the lock in order to use this memory. We can't forget; the type system won't let us do otherwise. As you may have suspected, `Mutex` is a smart pointer. Well, more @@ -187,10 +187,10 @@ like `Rc`, but made these counts thread-safe? If you thought that question sounded like a leading one, you'd be right. There is: `Arc`. The 'a' stands for 'atomic', so it's an 'atomically reference -counted' type. Atomics are an additional kind of concurrency primtive that we +counted' type. Atomics are an additional kind of concurrency primitive that we won't cover here, see the standard library documentation for `std::atomic` for more. The gist of it is this: they work like primitive types, but are safe to -share across threads. Why isn't this safety the default? Becuase it comes with +share across threads. Why isn't this safety the default? Because it comes with a performance penalty. Anyway, `Arc` and `Rc` are identical except for the atomic internals. The