diff --git a/public-trunk/CommonLibs/Threads.cpp b/public-trunk/CommonLibs/Threads.cpp index 2628ab1..6180c2d 100644 --- a/public-trunk/CommonLibs/Threads.cpp +++ b/public-trunk/CommonLibs/Threads.cpp @@ -72,16 +72,17 @@ void unlockCerr() Mutex::Mutex() { - assert(!pthread_mutexattr_init(&mAttribs)); - assert(!pthread_mutexattr_settype(&mAttribs,PTHREAD_MUTEX_RECURSIVE)); - assert(!pthread_mutex_init(&mMutex,&mAttribs)); + pthread_mutexattr_init(&mAttribs); + int s = pthread_mutexattr_settype(&mAttribs,PTHREAD_MUTEX_RECURSIVE); + assert(s!=0); + pthread_mutex_init(&mMutex,&mAttribs); } Mutex::~Mutex() { pthread_mutex_destroy(&mMutex); - assert(!pthread_mutexattr_destroy(&mAttribs)); + pthread_mutexattr_destroy(&mAttribs); } @@ -107,10 +108,15 @@ int ThreadSemaphore::wait(unsigned timeout) const void Thread::start(void *(*task)(void*), void *arg) { + int s; assert(mThread==((pthread_t)0)); - assert(!pthread_attr_init(&mAttrib)); - assert(!pthread_attr_setstacksize(&mAttrib, mStackSize)); - assert(!pthread_create(&mThread, &mAttrib, task, arg)); + + s = pthread_attr_init(&mAttrib); + assert(s == 0); + s = pthread_attr_setstacksize(&mAttrib, mStackSize); + assert(s == 0); + s = pthread_create(&mThread, &mAttrib, task, arg); + assert(s == 0); } diff --git a/public-trunk/CommonLibs/Threads.h b/public-trunk/CommonLibs/Threads.h index 4b65215..f390d9a 100644 --- a/public-trunk/CommonLibs/Threads.h +++ b/public-trunk/CommonLibs/Threads.h @@ -98,7 +98,7 @@ class Signal { public: - Signal() { assert(!pthread_cond_init(&mSignal,NULL)); } + Signal() { int s = pthread_cond_init(&mSignal,NULL); assert(s == 0); } ~Signal() { pthread_cond_destroy(&mSignal); } @@ -176,14 +176,14 @@ class Thread { Destroy the Thread. It should be stopped and joined. */ - ~Thread() { assert(!pthread_attr_destroy(&mAttrib)); } + ~Thread() { int s = pthread_attr_destroy(&mAttrib); assert(s==0); } /** Start the thread on a task. */ void start(void *(*task)(void*), void *arg); /** Join a thread that will stop on its own. */ - void join() { assert(!pthread_join(mThread,NULL)); } + void join() { int s = pthread_join(mThread,NULL); assert(s==0); } };