Merge pull request #519 from Unconnectable/update/atomics-examples

Fix deprecation warning for compare_and_swap in atomics.md
master
Yuki Okushi 7 days ago committed by GitHub
commit b8f254a991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -206,7 +206,7 @@ fn main() {
// ... distribute lock to threads somehow ... // ... distribute lock to threads somehow ...
// Try to acquire the lock by setting it to true // Try to acquire the lock by setting it to true
while lock.compare_and_swap(false, true, Ordering::Acquire) { } while lock.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed).is_err() { }
// broke out of the loop, so we successfully acquired the lock! // broke out of the loop, so we successfully acquired the lock!
// ... scary data accesses ... // ... scary data accesses ...

Loading…
Cancel
Save