X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6cd4655bee404d94e1f0eb4d880e24668c842dfd..75625d796cb7ea32ecb2c0526159180cb2352680:/src/msw/thread.cpp?ds=sidebyside diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 27ab616999..df5f2f2ba7 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -32,6 +32,7 @@ #if wxUSE_THREADS #include "wx/msw/private.h" +#include "wx/msw/missing.h" #include "wx/module.h" #include "wx/thread.h" @@ -79,11 +80,6 @@ #define THREAD_CALLCONV WINAPI #endif -// the old mingw32 headers don't have this one -#ifndef QS_ALLPOSTMESSAGE - #define QS_ALLPOSTMESSAGE 0x0100 -#endif - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -178,6 +174,8 @@ private: wxMutexError LockTimeout(DWORD milliseconds); HANDLE m_mutex; + + DECLARE_NO_COPY_CLASS(wxMutexInternal) }; // all mutexes are recursive under Win32 so we don't use mutexType @@ -247,7 +245,7 @@ wxMutexError wxMutexInternal::Unlock() { if ( !::ReleaseMutex(m_mutex) ) { - wxLogLastError(_("ReleaseMutex()")); + wxLogLastError(_T("ReleaseMutex()")); return wxMUTEX_MISC_ERROR; } @@ -269,13 +267,24 @@ public: bool IsOk() const { return m_semaphore != NULL; } wxSemaError Wait() { return WaitTimeout(INFINITE); } - wxSemaError TryWait() { return WaitTimeout(0); } + + wxSemaError TryWait() + { + wxSemaError rc = WaitTimeout(0); + if ( rc == wxSEMA_TIMEOUT ) + rc = wxSEMA_BUSY; + + return rc; + } + wxSemaError WaitTimeout(unsigned long milliseconds); wxSemaError Post(); private: HANDLE m_semaphore; + + DECLARE_NO_COPY_CLASS(wxSemaphoreInternal) }; wxSemaphoreInternal::wxSemaphoreInternal(int initialcount, int maxcount) @@ -321,7 +330,7 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds) return wxSEMA_NO_ERROR; case WAIT_TIMEOUT: - return wxSEMA_BUSY; + return wxSEMA_TIMEOUT; default: wxLogLastError(_T("WaitForSingleObject(semaphore)")); @@ -540,6 +549,8 @@ private: wxThreadState m_state; // state, see wxThreadState enum unsigned int m_priority; // thread priority in "wx" units DWORD m_tid; // thread id + + DECLARE_NO_COPY_CLASS(wxThreadInternal) }; THREAD_RETVAL THREAD_CALLCONV wxThreadInternal::WinThreadStart(void *param) @@ -618,6 +629,9 @@ void wxThreadInternal::SetPriority(unsigned int priority) bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize) { + wxASSERT_MSG( m_state == STATE_NEW && !m_hThread, + _T("Create()ing thread twice?") ); + // for compilers which have it, we should use C RTL function for thread // creation instead of Win32 API one because otherwise we will have memory // leaks if the thread uses C RTL (and most threads do)