diff options
author | rubidium <rubidium@openttd.org> | 2010-09-17 16:24:26 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-09-17 16:24:26 +0000 |
commit | a15d179edfcfc1d3e6928cd75ad538d5fc7b5b59 (patch) | |
tree | f1071bf8904a17a93284dcc749ad0bdaff169c39 | |
parent | 410d48cbb8bd738952a211034beab352f079ae02 (diff) | |
download | openttd-a15d179edfcfc1d3e6928cd75ad538d5fc7b5b59.tar.xz |
(svn r20823) -Codechange: enable/add some error/sanity checking in the pthread code
-rw-r--r-- | src/thread/thread_pthread.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/thread/thread_pthread.cpp b/src/thread/thread_pthread.cpp index ca1fb8f5a..e2af7bac4 100644 --- a/src/thread/thread_pthread.cpp +++ b/src/thread/thread_pthread.cpp @@ -97,11 +97,14 @@ class ThreadMutex_pthread : public ThreadMutex { private: pthread_mutex_t mutex; pthread_cond_t condition; + pthread_mutexattr_t attr; public: ThreadMutex_pthread() { - pthread_mutex_init(&this->mutex, NULL); + pthread_mutexattr_init(&this->attr); + pthread_mutexattr_settype(&this->attr, PTHREAD_MUTEX_ERRORCHECK); + pthread_mutex_init(&this->mutex, &this->attr); pthread_cond_init(&this->condition, NULL); } @@ -115,22 +118,26 @@ public: /* virtual */ void BeginCritical() { - pthread_mutex_lock(&this->mutex); + int err = pthread_mutex_lock(&this->mutex); + assert(err == 0); } /* virtual */ void EndCritical() { - pthread_mutex_unlock(&this->mutex); + int err = pthread_mutex_unlock(&this->mutex); + assert(err == 0); } /* virtual */ void WaitForSignal() { - pthread_cond_wait(&this->condition, &this->mutex); + int err = pthread_cond_wait(&this->condition, &this->mutex); + assert(err == 0); } /* virtual */ void SendSignal() { - pthread_cond_signal(&this->condition); + int err = pthread_cond_signal(&this->condition); + assert(err == 0); } }; |