X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/550343399aa1355469ffed72c8cf84c732dcf98b..cb40fa312eee41ba47999a83743a697760ba5bb0:/src/os2/thread.cpp diff --git a/src/os2/thread.cpp b/src/os2/thread.cpp index 87d0c0611a..f0b8e6068e 100644 --- a/src/os2/thread.cpp +++ b/src/os2/thread.cpp @@ -6,7 +6,6 @@ // Created: 04/22/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Neis (2003) -// // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,15 +18,19 @@ #if wxUSE_THREADS -#include +#include "wx/thread.h" + +#ifndef WX_PRECOMP + #include "wx/intl.h" + #include "wx/log.h" + #include "wx/app.h" + #include "wx/module.h" +#endif //WX_PRECOMP -#include "wx/app.h" #include "wx/apptrait.h" -#include "wx/module.h" -#include "wx/intl.h" #include "wx/utils.h" -#include "wx/log.h" -#include "wx/thread.h" + +#include #define INCL_DOSSEMAPHORES #define INCL_DOSPROCESS @@ -93,7 +96,8 @@ public: bool IsOk() const { return m_vMutex != NULL; } wxMutexError Lock() { return LockTimeout(SEM_INDEFINITE_WAIT); } - wxMutexError TryLock() { return LockTimeout(SEM_IMMEDIATE_RETURN); } + wxMutexError Lock(unsigned long ms) { return LockTimeout(ms); } + wxMutexError TryLock(); wxMutexError Unlock(); private: @@ -124,6 +128,14 @@ wxMutexInternal::~wxMutexInternal() } } +wxMutexError wxMutexInternal::TryLock() +{ + const wxMutexError rc = LockTimeout( SEM_IMMEDIATE_RETURN ); + + // we have a special return code for timeout in this case + return rc == wxMUTEX_TIMEOUT ? wxMUTEX_BUSY : rc; +} + wxMutexError wxMutexInternal::LockTimeout(ULONG ulMilliseconds) { APIRET ulrc; @@ -133,6 +145,7 @@ wxMutexError wxMutexInternal::LockTimeout(ULONG ulMilliseconds) switch (ulrc) { case ERROR_TIMEOUT: + return wxMUTEX_TIMEOUT; case ERROR_TOO_MANY_SEM_REQUESTS: return wxMUTEX_BUSY; @@ -556,13 +569,6 @@ void wxThread::Yield() ::DosSleep(0); } -void wxThread::Sleep( - unsigned long ulMilliseconds -) -{ - ::DosSleep(ulMilliseconds); -} - int wxThread::GetCPUCount() { ULONG CPUCount; @@ -972,7 +978,7 @@ void WXDLLEXPORT wxWakeUpMainThread() #endif } -void WXDLLEXPORT wxMutexGuiEnter() +void wxMutexGuiEnterImpl() { // this would dead lock everything... wxASSERT_MSG( !wxThread::IsMain(), @@ -994,7 +1000,7 @@ void WXDLLEXPORT wxMutexGuiEnter() gs_pCritsectGui->Enter(); } -void WXDLLEXPORT wxMutexGuiLeave() +void wxMutexGuiLeaveImpl() { wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui);