From b34786c4d489bea0fdcd07678780d120001c9b8e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 Jun 2023 02:16:52 +0300 Subject: [PATCH] Interleave calls to sp_thread_pause and sp_thread_sleep in yield_k, instead of doing a single pause at 0 --- include/boost/smart_ptr/detail/yield_k.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/smart_ptr/detail/yield_k.hpp b/include/boost/smart_ptr/detail/yield_k.hpp index f226d86..7f6c645 100644 --- a/include/boost/smart_ptr/detail/yield_k.hpp +++ b/include/boost/smart_ptr/detail/yield_k.hpp @@ -32,13 +32,13 @@ inline void yield( unsigned k ) // Experiments on Windows and Fedora 32 show that a single pause, // followed by an immediate sp_thread_sleep(), is best. - if( k == 0 ) + if( k & 1 ) { - boost::core::sp_thread_pause(); + boost::core::sp_thread_sleep(); } else { - boost::core::sp_thread_sleep(); + boost::core::sp_thread_pause(); } }