cwThread.h/cpp : thread_id_t is changed form unsigned to unsigned long long.

This commit is contained in:
kpl 2020-01-27 17:50:57 -05:00
parent 46b42b34ef
commit 8fbd2fee2d
2 changed files with 18 additions and 3 deletions

View File

@ -204,8 +204,21 @@ cw::thread::stateId_t cw::thread::state( handle_t h )
return p->stateId; return p->stateId;
} }
unsigned cw::thread::id() cw::thread::thread_id_t cw::thread::id()
{ return static_cast<unsigned>(pthread_self()); } {
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 namespace cw
{ {

View File

@ -17,6 +17,8 @@ namespace cw
typedef bool (*cbFunc_t)( void* arg ); 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. // 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. // 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 ); 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 ); stateId_t state( handle_t h );
// Return the thread id of the calling context. // Return the thread id of the calling context.
unsigned id(); thread_id_t id();
} }
rc_t threadTest(); rc_t threadTest();
} }