about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorMathijs van de Nes <git@mathijs.vd-nes.nl>2014-07-10 11:51:19 +0200
committerMathijs van de Nes <git@mathijs.vd-nes.nl>2014-07-10 11:55:04 +0200
commitc22b22d7b136a0ba27e4c8b5c634d651169684a8 (patch)
tree02c7aed8f7c8b03bdcab0b8492b4a02b71567c67 /src/libcore
parent6372915a78a12adfbc327aba87225988ae03e7f9 (diff)
downloadrust-c22b22d7b136a0ba27e4c8b5c634d651169684a8.tar.gz
rust-c22b22d7b136a0ba27e4c8b5c634d651169684a8.zip
Mistake in AtomicBool spinlock example
The current example of a spinlock was not correct. The lock is actually acquired
when old == result. So we only need to deschedule when this is not the case.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/atomics.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/atomics.rs b/src/libcore/atomics.rs
index 971799acc78..e022fa2c370 100644
--- a/src/libcore/atomics.rs
+++ b/src/libcore/atomics.rs
@@ -141,7 +141,7 @@ impl AtomicBool {
     ///
     /// fn with_lock(spinlock: &Arc<AtomicBool>, f: || -> ()) {
     ///     // CAS loop until we are able to replace `false` with `true`
-    ///     while spinlock.compare_and_swap(false, true, SeqCst) == false {
+    ///     while spinlock.compare_and_swap(false, true, SeqCst) != false {
     ///         // Since tasks may not be preemptive (if they are green threads)
     ///         // yield to the scheduler to let the other task run. Low level
     ///         // concurrent code needs to take into account Rust's two threading