From 0fe193f199fced0b32e0c67131af1026e77cd2a5 Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 19 Sep 2014 13:43:05 +0400 Subject: [PATCH] Replace cds::OS::yield() with std::this_thread::yield() --- cds/os/posix/thread.h | 16 ++++------------ cds/os/win/thread.h | 13 +------------ 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/cds/os/posix/thread.h b/cds/os/posix/thread.h index 0b5001a0..da77ea65 100644 --- a/cds/os/posix/thread.h +++ b/cds/os/posix/thread.h @@ -3,14 +3,7 @@ #ifndef __CDS_OS_POSIX_THREAD_H #define __CDS_OS_POSIX_THREAD_H -#include // system #include -#include -#include -#include -#include -#include -#include namespace cds { namespace OS { /// posix-related wrappers @@ -24,16 +17,15 @@ namespace cds { namespace OS { return pthread_kill( id, 0 ) != ESRCH; } - /// Yield thread - static inline void yield() { sched_yield(); } - /// Default back-off thread strategy (yield) - static inline void backoff() { sched_yield(); } + static inline void backoff() + { + std::this_thread::yield(); + } } // namespace posix using posix::isThreadAlive; - using posix::yield; using posix::backoff; }} // namespace cds::OS diff --git a/cds/os/win/thread.h b/cds/os/win/thread.h index 0bbd94ef..e7feb557 100644 --- a/cds/os/win/thread.h +++ b/cds/os/win/thread.h @@ -19,25 +19,14 @@ namespace cds { namespace OS { return true; } - /// Yield current thread, switch to another - static inline void yield() - { - # if _WIN32_WINNT >= 0x0400 - ::SwitchToThread(); - # else - ::Sleep(0); - # endif - } - /// Default backoff::yield implementation static inline void backoff() { - yield(); + std::this_thread::yield(); } } // namespace Win32 using Win32::isThreadAlive; - using Win32::yield; using Win32::backoff; }} // namespace cds::OS -- 2.34.1