#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
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
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