Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:28

0001 #ifndef BOOST_CORE_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
0002 #define BOOST_CORE_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 // boost/core/detail/sp_thread_yield.hpp
0011 //
0012 // inline void bost::core::sp_thread_yield();
0013 //
0014 //   Gives up the remainder of the time slice,
0015 //   as if by calling sched_yield().
0016 //
0017 // Copyright 2008, 2020 Peter Dimov
0018 // Distributed under the Boost Software License, Version 1.0
0019 // https://www.boost.org/LICENSE_1_0.txt
0020 
0021 #include <boost/config.hpp>
0022 #include <boost/config/pragma_message.hpp>
0023 
0024 #if defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
0025 
0026 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
0027   BOOST_PRAGMA_MESSAGE("Using SwitchToThread() in sp_thread_yield")
0028 #endif
0029 
0030 #include <boost/core/detail/sp_win32_sleep.hpp>
0031 
0032 namespace boost
0033 {
0034 namespace core
0035 {
0036 namespace detail
0037 {
0038 
0039 inline void sp_thread_yield() BOOST_NOEXCEPT
0040 {
0041     SwitchToThread();
0042 }
0043 
0044 } // namespace detail
0045 
0046 using boost::core::detail::sp_thread_yield;
0047 
0048 } // namespace core
0049 } // namespace boost
0050 
0051 #elif defined(BOOST_HAS_SCHED_YIELD)
0052 
0053 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
0054   BOOST_PRAGMA_MESSAGE("Using sched_yield() in sp_thread_yield")
0055 #endif
0056 
0057 #ifndef _AIX
0058 # include <sched.h>
0059 #else
0060   // AIX's sched.h defines ::var which sometimes conflicts with Lambda's var
0061   extern "C" int sched_yield(void);
0062 #endif
0063 
0064 namespace boost
0065 {
0066 namespace core
0067 {
0068 
0069 inline void sp_thread_yield() BOOST_NOEXCEPT
0070 {
0071     sched_yield();
0072 }
0073 
0074 } // namespace core
0075 } // namespace boost
0076 
0077 #else
0078 
0079 #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
0080   BOOST_PRAGMA_MESSAGE("Using sp_thread_pause() in sp_thread_yield")
0081 #endif
0082 
0083 #include <boost/core/detail/sp_thread_pause.hpp>
0084 
0085 namespace boost
0086 {
0087 namespace core
0088 {
0089 
0090 inline void sp_thread_yield() BOOST_NOEXCEPT
0091 {
0092     sp_thread_pause();
0093 }
0094 
0095 } // namespace core
0096 } // namespace boost
0097 
0098 #endif
0099 
0100 #endif // #ifndef BOOST_CORE_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED