3 #ifndef __CDS_OS_WIN_THREAD_H
4 #define __CDS_OS_WIN_THREAD_H
8 namespace cds { namespace OS {
9 /// Windows-specific functions
12 /// OS-specific type of thread identifier
13 typedef DWORD ThreadId;
15 /// OS-specific type of thread handle
16 typedef HANDLE ThreadHandle;
18 /// Get null thread id
19 CDS_CONSTEXPR static inline ThreadId nullThreadId()
24 /// Get current thread id
25 static inline ThreadId getCurrentThreadId()
27 return ::GetCurrentThreadId();
30 /// Tests whether the thread is alive
31 static inline bool isThreadAlive( ThreadId id )
33 HANDLE h = ::OpenThread( SYNCHRONIZE, FALSE, id );
40 /// Yield current thread, switch to another
41 static inline void yield()
43 # if _WIN32_WINNT >= 0x0400
50 /// Default backoff::yield implementation
51 static inline void backoff()
57 using Win32::ThreadId;
58 using Win32::ThreadHandle;
60 using Win32::nullThreadId;
61 using Win32::getCurrentThreadId;
62 using Win32::isThreadAlive;
66 }} // namespace cds::OS
68 #endif // #ifndef __CDS_OS_WIN_THREAD_H