diff options
| author | bors <bors@rust-lang.org> | 2014-07-11 10:21:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-11 10:21:42 +0000 |
| commit | ca56650d4069e77b6885d8b44adc20545006f83d (patch) | |
| tree | 251c66534a94e9922733d18a4fcf6462825a15e9 | |
| parent | 559cf9288974e9e2f6ad238d6485e7f96cd55b66 (diff) | |
| parent | c22b22d7b136a0ba27e4c8b5c634d651169684a8 (diff) | |
| download | rust-ca56650d4069e77b6885d8b44adc20545006f83d.tar.gz rust-ca56650d4069e77b6885d8b44adc20545006f83d.zip | |
auto merge of #15575 : mvdnes/rust/spinlock_error, r=alexcrichton
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.
| -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 |
