projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reverted yet another accidental commit of testing code in r57505
[wxWidgets.git]
/
src
/
unix
/
threadpsx.cpp
diff --git
a/src/unix/threadpsx.cpp
b/src/unix/threadpsx.cpp
index 8e7d9bba9fd26fe9748bc2dad00a067a2519914a..692be7d169bc96e1179749c0fc86f7b9268fd0fe 100644
(file)
--- a/
src/unix/threadpsx.cpp
+++ b/
src/unix/threadpsx.cpp
@@
-178,6
+178,8
@@
private:
private:
pthread_mutex_t m_mutex;
bool m_isOk;
private:
pthread_mutex_t m_mutex;
bool m_isOk;
+ wxMutexType m_type;
+ unsigned long m_owningThread;
// wxConditionInternal uses our m_mutex
friend class wxConditionInternal;
// wxConditionInternal uses our m_mutex
friend class wxConditionInternal;
@@
-192,6
+194,9
@@
extern "C" int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
wxMutexInternal::wxMutexInternal(wxMutexType mutexType)
{
wxMutexInternal::wxMutexInternal(wxMutexType mutexType)
{
+ m_type = mutexType;
+ m_owningThread = 0;
+
int err;
switch ( mutexType )
{
int err;
switch ( mutexType )
{
@@
-252,6
+257,12
@@
wxMutexInternal::~wxMutexInternal()
wxMutexError wxMutexInternal::Lock()
{
wxMutexError wxMutexInternal::Lock()
{
+ if ((m_type == wxMUTEX_DEFAULT) && (m_owningThread != 0))
+ {
+ if (m_owningThread == wxThread::GetCurrentId())
+ return wxMUTEX_DEAD_LOCK;
+ }
+
return HandleLockResult(pthread_mutex_lock(&m_mutex));
}
return HandleLockResult(pthread_mutex_lock(&m_mutex));
}
@@
-307,6
+318,8
@@
wxMutexError wxMutexInternal::Lock(unsigned long ms)
wxMutexError wxMutexInternal::HandleLockResult(int err)
{
wxMutexError wxMutexInternal::HandleLockResult(int err)
{
+ // wxPrintf( "err %d\n", err );
+
switch ( err )
{
case EDEADLK:
switch ( err )
{
case EDEADLK:
@@
-323,6
+336,8
@@
wxMutexError wxMutexInternal::HandleLockResult(int err)
return wxMUTEX_TIMEOUT;
case 0:
return wxMUTEX_TIMEOUT;
case 0:
+ if (m_type == wxMUTEX_DEFAULT)
+ m_owningThread = wxThread::GetCurrentId();
return wxMUTEX_NO_ERROR;
default:
return wxMUTEX_NO_ERROR;
default:
@@
-348,6
+363,8
@@
wxMutexError wxMutexInternal::TryLock()
break;
case 0:
break;
case 0:
+ if (m_type == wxMUTEX_DEFAULT)
+ m_owningThread = wxThread::GetCurrentId();
return wxMUTEX_NO_ERROR;
default:
return wxMUTEX_NO_ERROR;
default:
@@
-359,6
+376,8
@@
wxMutexError wxMutexInternal::TryLock()
wxMutexError wxMutexInternal::Unlock()
{
wxMutexError wxMutexInternal::Unlock()
{
+ m_owningThread = 0;
+
int err = pthread_mutex_unlock(&m_mutex);
switch ( err )
{
int err = pthread_mutex_unlock(&m_mutex);
switch ( err )
{
@@
-1050,11
+1069,6
@@
void wxThread::Yield()
#endif
}
#endif
}
-void wxThread::Sleep(unsigned long milliseconds)
-{
- wxMilliSleep(milliseconds);
-}
-
int wxThread::GetCPUCount()
{
#if defined(_SC_NPROCESSORS_ONLN)
int wxThread::GetCPUCount()
{
#if defined(_SC_NPROCESSORS_ONLN)