diff --git a/cwThread.cpp b/cwThread.cpp index 7a923e0..78222a1 100644 --- a/cwThread.cpp +++ b/cwThread.cpp @@ -204,8 +204,21 @@ cw::thread::stateId_t cw::thread::state( handle_t h ) return p->stateId; } -unsigned cw::thread::id() -{ return static_cast(pthread_self()); } +cw::thread::thread_id_t cw::thread::id() +{ + typedef struct + { + union + { + thread_id_t id; + pthread_t pthread_id; + } u; + } id_t; + + id_t id; + id.u.pthread_id = pthread_self(); + return id.u.id; +} namespace cw { diff --git a/cwThread.h b/cwThread.h index 0b119f0..287dbc8 100644 --- a/cwThread.h +++ b/cwThread.h @@ -17,6 +17,8 @@ namespace cw typedef bool (*cbFunc_t)( void* arg ); + typedef unsigned long long thread_id_t; + // stateMicros = total time out duration for switching to the exit state or for switching in/out of pause state. // pauseMicros = duration of thread sleep interval when in paused state. rc_t create( handle_t& hRef, cbFunc_t func, void* funcArg, int stateTimeOutMicros=100000, int pauseMicros=10000 ); @@ -30,7 +32,7 @@ namespace cw stateId_t state( handle_t h ); // Return the thread id of the calling context. - unsigned id(); + thread_id_t id(); } rc_t threadTest(); }