diff options
| author | Mathijs van de Nes <git@mathijs.vd-nes.nl> | 2014-07-10 11:51:19 +0200 |
|---|---|---|
| committer | Mathijs van de Nes <git@mathijs.vd-nes.nl> | 2014-07-10 11:55:04 +0200 |
| commit | c22b22d7b136a0ba27e4c8b5c634d651169684a8 (patch) | |
| tree | 02c7aed8f7c8b03bdcab0b8492b4a02b71567c67 /src/libcore | |
| parent | 6372915a78a12adfbc327aba87225988ae03e7f9 (diff) | |
| download | rust-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.rs | 2 |
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 |
