Skip to content

Replace deprecated function compare_and_swap#42

Open
iron9light wants to merge 1 commit intospacejam:masterfrom
iron9light:fix_compare_and_swap
Open

Replace deprecated function compare_and_swap#42
iron9light wants to merge 1 commit intospacejam:masterfrom
iron9light:fix_compare_and_swap

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

3 participants