Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated function compare_and_swap #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iron9light
Copy link

AtomicBool::compare_and_swap was deprecated since 1.50.0.
Replace it with AtomicBool::compare_exchange.

@CLAassistant
Copy link

CLAassistant commented Feb 16, 2021

CLA assistant check
All committers have signed the CLA.

// looping as long as it returns true, so we don't need
// any explicit conversion here.
while self.init_mu.compare_and_swap(false, true, SeqCst) {}
while self.init_mu.compare_exchange(false, true, SeqCst, SeqCst).unwrap_or_else(|x| x) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be more concise

Suggested change
while self.init_mu.compare_exchange(false, true, SeqCst, SeqCst).unwrap_or_else(|x| x) {}
while self
.init_mu
.compare_exchange(false, true, SeqCst, SeqCst)
.is_err()
{}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants