File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -324,12 +324,18 @@ impl AtomicUsize {
324324 }
325325
326326 #[ cfg( atomic_cas) ]
327- fn compare_and_swap ( & self , current : usize , new : usize , _order : Ordering ) -> usize {
327+ fn compare_exchange (
328+ & self ,
329+ current : usize ,
330+ new : usize ,
331+ _success : Ordering ,
332+ _failure : Ordering ,
333+ ) -> Result < usize , usize > {
328334 let prev = self . v . get ( ) ;
329335 if current == prev {
330336 self . v . set ( new) ;
331337 }
332- prev
338+ Ok ( prev)
333339 }
334340}
335341
@@ -1338,7 +1344,15 @@ fn set_logger_inner<F>(make_logger: F) -> Result<(), SetLoggerError>
13381344where
13391345 F : FnOnce ( ) -> & ' static dyn Log ,
13401346{
1341- match STATE . compare_and_swap ( UNINITIALIZED , INITIALIZING , Ordering :: SeqCst ) {
1347+ let old_state = match STATE . compare_exchange (
1348+ UNINITIALIZED ,
1349+ INITIALIZING ,
1350+ Ordering :: SeqCst ,
1351+ Ordering :: SeqCst ,
1352+ ) {
1353+ Ok ( s) | Err ( s) => s,
1354+ } ;
1355+ match old_state {
13421356 UNINITIALIZED => {
13431357 unsafe {
13441358 LOGGER = make_logger ( ) ;
You can’t perform that action at this time.
0 commit comments