Renamed isThreadAlive to is_thread_alive
[libcds.git] / cds / os / win / thread.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_OS_WIN_THREAD_H
4 #define __CDS_OS_WIN_THREAD_H
5
6 #include <windows.h>
7
8 namespace cds { namespace OS {
9     /// Windows-specific functions
10     CDS_CXX11_INLINE_NAMESPACE namespace Win32 {
11
12         /// OS-specific type of thread identifier
13         typedef DWORD           ThreadId;
14
15         /// Get current thread id
16         static inline ThreadId get_current_thread_id()
17         {
18             return ::GetCurrentThreadId();
19         }
20
21         /// Tests whether the thread is alive
22         static inline bool is_thread_alive( ThreadId id )
23         {
24             HANDLE h = ::OpenThread( SYNCHRONIZE, FALSE, id );
25             if ( h == nullptr )
26                 return false;
27             ::CloseHandle( h );
28             return true;
29         }
30     }    // namespace Win32
31
32     //@cond
33     CDS_CONSTEXPR const Win32::ThreadId c_NullThreadId = 0;
34
35 #ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
36     using Win32::ThreadId;
37     using Win32::get_current_thread_id;
38     using Win32::is_thread_alive;
39 #endif
40     //@endcond
41
42 }} // namespace cds::OS
43
44 #endif // #ifndef __CDS_OS_WIN_THREAD_H