3 #ifndef __CDS_OS_POSIX_THREAD_H
4 #define __CDS_OS_POSIX_THREAD_H
9 namespace cds { namespace OS {
10 /// posix-related wrappers
11 inline namespace posix {
13 /// Posix thread id type
14 typedef std::thread::native_handle_type ThreadId;
16 /// Get current thread id
17 static inline ThreadId get_current_thread_id()
19 return pthread_self();
22 /// Checks if thread \p id is alive
23 static inline bool is_thread_alive( ThreadId id )
25 // if sig is zero, error checking is performed but no signal is actually sent.
26 // ESRCH - No thread could be found corresponding to that specified by the given thread ID
27 // Unresolved problem: Linux may crash on dead thread_id. Workaround unknown (except signal handler...)
28 return pthread_kill( id, 0 ) != ESRCH;
33 constexpr const posix::ThreadId c_NullThreadId = 0;
36 }} // namespace cds::OS
39 #endif // #ifndef __CDS_OS_POSIX_THREAD_H