diff options
Diffstat (limited to 'boost/smart_ptr/detail/yield_k.hpp')
-rw-r--r-- | boost/smart_ptr/detail/yield_k.hpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/boost/smart_ptr/detail/yield_k.hpp b/boost/smart_ptr/detail/yield_k.hpp index 23eadd808b..2dabc9f443 100644 --- a/boost/smart_ptr/detail/yield_k.hpp +++ b/boost/smart_ptr/detail/yield_k.hpp @@ -11,6 +11,7 @@ // yield_k.hpp // // Copyright (c) 2008 Peter Dimov +// Copyright (c) Microsoft Corporation 2014 // // void yield( unsigned k ); // @@ -24,13 +25,17 @@ // #include <boost/config.hpp> +#include <boost/predef.h> + +#if BOOST_PLAT_WINDOWS_RUNTIME +#include <thread> +#endif // BOOST_SMT_PAUSE #if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) extern "C" void _mm_pause(); -#pragma intrinsic( _mm_pause ) #define BOOST_SMT_PAUSE _mm_pause(); @@ -54,7 +59,7 @@ namespace boost namespace detail { -#if !defined( BOOST_USE_WINDOWS_H ) +#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME extern "C" void __stdcall Sleep( unsigned long ms ); #endif @@ -69,6 +74,7 @@ inline void yield( unsigned k ) BOOST_SMT_PAUSE } #endif +#if !BOOST_PLAT_WINDOWS_RUNTIME else if( k < 32 ) { Sleep( 0 ); @@ -77,6 +83,13 @@ inline void yield( unsigned k ) { Sleep( 1 ); } +#else + else + { + // Sleep isn't supported on the Windows Runtime. + std::this_thread::yield(); + } +#endif } } // namespace detail @@ -85,7 +98,13 @@ inline void yield( unsigned k ) #elif defined( BOOST_HAS_PTHREADS ) +#ifndef _AIX #include <sched.h> +#else + // AIX's sched.h defines ::var which sometimes conflicts with Lambda's var + extern "C" int sched_yield(void); +#endif + #include <time.h> namespace boost |