From b6b00c2de629e0a9e74c39f88e43e32d49a95c38 Mon Sep 17 00:00:00 2001 From: iron9light Date: Wed, 17 Feb 2021 05:11:09 +0800 Subject: [PATCH] Replace deprecated function compare_and_swap --- src/lazy.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lazy.rs b/src/lazy.rs index 7405897..c134a5d 100644 --- a/src/lazy.rs +++ b/src/lazy.rs @@ -54,11 +54,11 @@ where } } - // compare_and_swap returns the last value on success, - // or the current value on failure. We want to keep + // compare_exchange returns Ok with the last value on success, + // or Err with the current value on failure. We want to keep // 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) {} { let value_ptr = self.value.load(SeqCst);