From: khizmax Date: Fri, 19 Sep 2014 09:43:05 +0000 (+0400) Subject: Replace cds::OS::yield() with std::this_thread::yield() X-Git-Tag: v2.0.0~329 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=0fe193f199fced0b32e0c67131af1026e77cd2a5;p=libcds.git Replace cds::OS::yield() with std::this_thread::yield() --- 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