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:
commit
ca56650d40
1 changed files with 1 additions and 1 deletions
|
@ -141,7 +141,7 @@ impl AtomicBool {
|
||||||
///
|
///
|
||||||
/// fn with_lock(spinlock: &Arc<AtomicBool>, f: || -> ()) {
|
/// fn with_lock(spinlock: &Arc<AtomicBool>, f: || -> ()) {
|
||||||
/// // CAS loop until we are able to replace `false` with `true`
|
/// // 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)
|
/// // Since tasks may not be preemptive (if they are green threads)
|
||||||
/// // yield to the scheduler to let the other task run. Low level
|
/// // yield to the scheduler to let the other task run. Low level
|
||||||
/// // concurrent code needs to take into account Rust's two threading
|
/// // concurrent code needs to take into account Rust's two threading
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue