diff options
| author | Jake Kerr <kodafox@gmail.com> | 2015-09-01 17:20:04 +0900 |
|---|---|---|
| committer | Jake Kerr <kodafox@gmail.com> | 2015-09-01 17:32:22 +0900 |
| commit | 8213f01a76a6114ff145f5d5cec335671d3b6c7e (patch) | |
| tree | 1f6f4f06e8c333b3fa09034a0a5aac920717fbca | |
| parent | 7d78f2d333b323b0ce155152ae2e648450bffb01 (diff) | |
| download | rust-8213f01a76a6114ff145f5d5cec335671d3b6c7e.tar.gz rust-8213f01a76a6114ff145f5d5cec335671d3b6c7e.zip | |
Reverse AtomicBool value in nomicon example to agree with its comment.
Makes the code agree with the comment: 'value answers "am I locked?"'.
| -rw-r--r-- | src/doc/nomicon/atomics.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/doc/nomicon/atomics.md b/src/doc/nomicon/atomics.md index d781e59d7c9..08f0de4f006 100644 --- a/src/doc/nomicon/atomics.md +++ b/src/doc/nomicon/atomics.md @@ -210,18 +210,18 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::thread; fn main() { - let lock = Arc::new(AtomicBool::new(true)); // value answers "am I locked?" + let lock = Arc::new(AtomicBool::new(false)); // value answers "am I locked?" // ... distribute lock to threads somehow ... - // Try to acquire the lock by setting it to false - while !lock.compare_and_swap(true, false, Ordering::Acquire) { } + // Try to acquire the lock by setting it to true + while lock.compare_and_swap(false, true, Ordering::Acquire) { } // broke out of the loop, so we successfully acquired the lock! // ... scary data accesses ... // ok we're done, release the lock - lock.store(true, Ordering::Release); + lock.store(false, Ordering::Release); } ``` |
