* Thread updates and cleanup (m_locked, MUTEX_UNLOCKED added)
* Updated the documentation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@94 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -51,13 +51,15 @@ wxMutex::wxMutex()
|
||||
{
|
||||
p_internal = new wxMutexInternal;
|
||||
pthread_mutex_init(&(p_internal->p_mutex), NULL);
|
||||
m_locked = false;
|
||||
m_locked = 0;
|
||||
}
|
||||
|
||||
wxMutex::~wxMutex()
|
||||
{
|
||||
if (m_locked)
|
||||
pthread_mutex_unlock(&(p_internal->p_mutex));
|
||||
if (m_locked > 0)
|
||||
wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n",
|
||||
m_locked);
|
||||
|
||||
pthread_mutex_destroy(&(p_internal->p_mutex));
|
||||
delete p_internal;
|
||||
}
|
||||
@@ -67,9 +69,8 @@ wxMutexError wxMutex::Lock()
|
||||
int err;
|
||||
|
||||
err = pthread_mutex_lock(&(p_internal->p_mutex));
|
||||
switch (err) {
|
||||
case EDEADLK: return MUTEX_DEAD_LOCK;
|
||||
}
|
||||
if (err == EDEADLK)
|
||||
return MUTEX_DEAD_LOCK;
|
||||
m_locked++;
|
||||
return MUTEX_NO_ERROR;
|
||||
}
|
||||
@@ -90,7 +91,10 @@ wxMutexError wxMutex::TryLock()
|
||||
|
||||
wxMutexError wxMutex::Unlock()
|
||||
{
|
||||
if (m_locked > 0) m_locked--;
|
||||
if (m_locked > 0)
|
||||
m_locked--;
|
||||
else
|
||||
return MUTEX_UNLOCKED;
|
||||
pthread_mutex_unlock(&(p_internal->p_mutex));
|
||||
return MUTEX_NO_ERROR;
|
||||
}
|
||||
|
Reference in New Issue
Block a user