summaryrefslogtreecommitdiff
path: root/src/thread_pthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread_pthread.cpp')
-rw-r--r--src/thread_pthread.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/thread_pthread.cpp b/src/thread_pthread.cpp
index 87d524784..2ab3d43f7 100644
--- a/src/thread_pthread.cpp
+++ b/src/thread_pthread.cpp
@@ -83,3 +83,37 @@ private:
if (thread != NULL) *thread = to;
return true;
}
+
+/**
+ * POSIX pthread version of ThreadMutex.
+ */
+class ThreadMutex_pthread : public ThreadMutex {
+private:
+ pthread_mutex_t mutex;
+
+public:
+ ThreadMutex_pthread()
+ {
+ pthread_mutex_init(&this->mutex, NULL);
+ }
+
+ /* virtual */ ~ThreadMutex_pthread()
+ {
+ pthread_mutex_destroy(&this->mutex);
+ }
+
+ /* virtual */ void BeginCritical()
+ {
+ pthread_mutex_lock(&this->mutex);
+ }
+
+ /* virtual */ void EndCritical()
+ {
+ pthread_mutex_unlock(&this->mutex);
+ }
+};
+
+/* static */ ThreadMutex *ThreadMutex::New()
+{
+ return new ThreadMutex_pthread();
+}