aboutsummaryrefslogtreecommitdiff
path: root/src/jthread/pthread
diff options
context:
space:
mode:
Diffstat (limited to 'src/jthread/pthread')
-rw-r--r--src/jthread/pthread/jmutex.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/jthread/pthread/jmutex.cpp b/src/jthread/pthread/jmutex.cpp
index 29e0baac0..3dfad5e6c 100644
--- a/src/jthread/pthread/jmutex.cpp
+++ b/src/jthread/pthread/jmutex.cpp
@@ -29,7 +29,8 @@
JMutex::JMutex()
{
- initialized = false;
+ pthread_mutex_init(&mutex,NULL);
+ initialized = true;
}
JMutex::~JMutex()
@@ -40,19 +41,14 @@ JMutex::~JMutex()
int JMutex::Init()
{
- if (initialized)
- return ERR_JMUTEX_ALREADYINIT;
-
- pthread_mutex_init(&mutex,NULL);
- initialized = true;
- return 0;
+ return 0;
}
int JMutex::Lock()
{
if (!initialized)
return ERR_JMUTEX_NOTINIT;
-
+
pthread_mutex_lock(&mutex);
return 0;
}
@@ -61,7 +57,7 @@ int JMutex::Unlock()
{
if (!initialized)
return ERR_JMUTEX_NOTINIT;
-
+
pthread_mutex_unlock(&mutex);
return 0;
}