diff options
author | Pixel <pixel@nobis-crew.org> | 2011-12-04 01:19:09 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-12-04 01:20:10 -0800 |
commit | d440c3f50a918a932293ad98bcec96eaa4683222 (patch) | |
tree | 33e8e42a8e4506ae9da70cdb44dd133bde7f7219 /src/Threads.cc | |
parent | e5577eb7a643ce7885e5d14660a6d24254161622 (diff) |
Reworked some things in the architecture, mainly exceptions and asserts.
-) Removed Assert()
-) Added AAssert(), IAssert(), RAssert(), TAssert() and Failure()
-) Reworked all asserts in the code, and added meaningful messages to them.
-) Changed the way the startup code is generated; BALAU_STARTUP is no longer necessary.
Diffstat (limited to 'src/Threads.cc')
-rw-r--r-- | src/Threads.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Threads.cc b/src/Threads.cc index f6578ed..df19da2 100644 --- a/src/Threads.cc +++ b/src/Threads.cc @@ -17,11 +17,11 @@ Balau::Lock::Lock() { pthread_mutexattr_t attr; r = pthread_mutexattr_init(&attr); - Assert(r == 0); + RAssert(r == 0, "Couldn't initialize mutex attribute; r = %i", r); r = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - Assert(r == 0); + RAssert(r == 0, "Couldn't set mutex attribute; r = %i", r); r = pthread_mutex_init(&m_lock, &attr); - Assert(r == 0); + RAssert(r == 0, "Couldn't initialize mutex; r = %i", r); } void * Balau::ThreadHelper::threadProc(void * arg) { @@ -39,8 +39,10 @@ Balau::Thread::~Thread() { void * Balau::Thread::join() { void * r = NULL; - if (Atomic::CmpXChgBool(&m_joined, true, false)) + if (Atomic::CmpXChgBool(&m_joined, true, false)) { + threadExit(); pthread_join(m_thread, &r); + } return r; } @@ -49,9 +51,11 @@ void Balau::Thread::threadStart() { int r; r = pthread_attr_init(&attr); - Assert(r == 0); + RAssert(r == 0, "Couldn't initialize pthread attribute; r = %i", r); r = pthread_create(&m_thread, &attr, Balau::ThreadHelper::threadProc, this); - Assert(r == 0); + RAssert(r == 0, "Couldn't create pthread; r = %i", r); r = pthread_attr_destroy(&attr); - Assert(r == 0); + RAssert(r == 0, "Couldn't destroy pthread attribute; r = %i", r); } + +void Balau::Thread::threadExit() { } |