Replace cds::OS::yield() with std::this_thread::yield()
authorkhizmax <khizmax@gmail.com>
Fri, 19 Sep 2014 09:43:05 +0000 (13:43 +0400)
committerkhizmax <khizmax@gmail.com>
Fri, 19 Sep 2014 09:43:05 +0000 (13:43 +0400)
cds/os/posix/thread.h
cds/os/win/thread.h

index 0b5001a09bbaeb2c2515eb4ca31e3eb2020273f2..da77ea6593d0bd401b5b00457096eb17bd448ab7 100644 (file)
@@ -3,14 +3,7 @@
 #ifndef __CDS_OS_POSIX_THREAD_H
 #define __CDS_OS_POSIX_THREAD_H
 
-#include <stdlib.h>     // system
 #include <pthread.h>
-#include <sched.h>
-#include <signal.h>
-#include <cerrno>
-#include <cstdlib>
-#include <string>
-#include <string.h>
 
 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
index 0bbd94ef2cfe62c80f1bfd01f9eedc3fae77e229..e7feb557f4b1b59191d24df78eb8d34f9f523ce7 100644 (file)
@@ -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