Skip to content

Commit ca56650

Browse files
committed
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.
2 parents 559cf92 + c22b22d commit ca56650

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/atomics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl AtomicBool {
141141
///
142142
/// fn with_lock(spinlock: &Arc<AtomicBool>, f: || -> ()) {
143143
/// // CAS loop until we are able to replace `false` with `true`
144-
/// while spinlock.compare_and_swap(false, true, SeqCst) == false {
144+
/// while spinlock.compare_and_swap(false, true, SeqCst) != false {
145145
/// // Since tasks may not be preemptive (if they are green threads)
146146
/// // yield to the scheduler to let the other task run. Low level
147147
/// // concurrent code needs to take into account Rust's two threading

0 commit comments

Comments
 (0)