summaryrefslogtreecommitdiff
path: root/src/thread/thread_pthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/thread_pthread.cpp')
-rw-r--r--src/thread/thread_pthread.cpp17
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);
}
};