Use SwitchToThread instead of Sleep(0) is sp_thread_yield; the general consensus is that it's newer and 'smarter'

This commit is contained in:
Peter Dimov 2023-06-18 21:54:13 +03:00
parent 8d6d20059a
commit 66890c3f3d
2 changed files with 4 additions and 2 deletions

View File

@ -24,7 +24,7 @@
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using Sleep(0) in sp_thread_yield")
BOOST_PRAGMA_MESSAGE("Using SwitchToThread() in sp_thread_yield")
#endif
#include <boost/core/detail/sp_win32_sleep.hpp>
@ -38,7 +38,7 @@ namespace detail
inline void sp_thread_yield() BOOST_NOEXCEPT
{
Sleep( 0 );
SwitchToThread();
}
} // namespace detail

View File

@ -41,6 +41,8 @@ namespace detail
extern "C" __declspec(dllimport) void BOOST_CORE_SP_STDCALL Sleep( unsigned long ms );
#endif
extern "C" __declspec(dllimport) int BOOST_CORE_SP_STDCALL SwitchToThread();
#undef BOOST_CORE_SP_STDCALL
#endif // !defined( BOOST_USE_WINDOWS_H )