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.
This commit is contained in:
bors 2014-07-11 10:21:42 +00:00
commit ca56650d40

View File

@ -141,7 +141,7 @@ pub fn swap(&self, val: bool, order: Ordering) -> bool {
///
/// 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