X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/00fdc89da8987c07e4aa2c94bfef7bd0bd793b48..75d684d9f772126b02aaea7eedadc79cd24aaf32:/src/msw/thread.cpp diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 8028e928e1..ba50980e8e 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -105,7 +105,7 @@ wxMutex::wxMutex() wxMutex::~wxMutex() { if (m_locked > 0) - wxLogDebug("Warning: freeing a locked mutex (%d locks).", m_locked); + wxLogDebug(_T("Warning: freeing a locked mutex (%d locks)."), m_locked); CloseHandle(p_internal->p_mutex); } @@ -129,7 +129,7 @@ wxMutexError wxMutex::Lock() case WAIT_TIMEOUT: default: - wxFAIL_MSG("impossible return value in wxMutex::Lock"); + wxFAIL_MSG(_T("impossible return value in wxMutex::Lock")); } m_locked++; @@ -257,26 +257,21 @@ private: wxCriticalSection::wxCriticalSection() { - m_critsect = NULL; + m_critsect = new wxCriticalSectionInternal; } wxCriticalSection::~wxCriticalSection() { - if ( m_critsect ) - delete m_critsect; + delete m_critsect; } void wxCriticalSection::Enter() { - m_critsect = new wxCriticalSectionInternal; - ::EnterCriticalSection(*m_critsect); } void wxCriticalSection::Leave() { - wxCHECK_RET( m_critsect, "Leave() without matching Enter()" ); - ::LeaveCriticalSection(*m_critsect); } @@ -380,7 +375,7 @@ bool wxThreadInternal::Create(wxThread *thread) win_priority = THREAD_PRIORITY_HIGHEST; else { - wxFAIL_MSG("invalid value of thread priority parameter"); + wxFAIL_MSG(_T("invalid value of thread priority parameter")); win_priority = THREAD_PRIORITY_NORMAL; } @@ -445,6 +440,10 @@ bool wxThread::IsMain() return ::GetCurrentThreadId() == s_idMainThread; } +#ifdef Yield + #undef Yield +#endif + void wxThread::Yield() { // 0 argument to Sleep() is special @@ -576,7 +575,7 @@ wxThread::ExitCode wxThread::Delete() break; default: - wxFAIL_MSG("unexpected result of MsgWaitForMultipleObject"); + wxFAIL_MSG(_T("unexpected result of MsgWaitForMultipleObject")); } } while ( result != WAIT_OBJECT_0 ); @@ -595,7 +594,7 @@ wxThread::ExitCode wxThread::Delete() } wxASSERT_MSG( (LPVOID)rc != (LPVOID)STILL_ACTIVE, - "thread must be already terminated." ); + _T("thread must be already terminated.") ); ::CloseHandle(hThread); } @@ -626,7 +625,7 @@ void wxThread::Exit(void *status) ::ExitThread((DWORD)status); - wxFAIL_MSG("Couldn't return from ExitThread()!"); + wxFAIL_MSG(_T("Couldn't return from ExitThread()!")); } void wxThread::SetPriority(unsigned int prio) @@ -665,6 +664,13 @@ bool wxThread::IsAlive() const (p_internal->GetState() == STATE_PAUSED); } +bool wxThread::IsPaused() const +{ + wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); + + return (p_internal->GetState() == STATE_PAUSED); +} + bool wxThread::TestDestroy() { wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); @@ -764,7 +770,7 @@ void WXDLLEXPORT wxMutexGuiEnter() { // this would dead lock everything... wxASSERT_MSG( !wxThread::IsMain(), - "main thread doesn't want to block in wxMutexGuiEnter()!" ); + _T("main thread doesn't want to block in wxMutexGuiEnter()!") ); // the order in which we enter the critical sections here is crucial!! @@ -794,7 +800,7 @@ void WXDLLEXPORT wxMutexGuiLeave() { // decrement the number of waiters now wxASSERT_MSG( s_nWaitingForGui > 0, - "calling wxMutexGuiLeave() without entering it first?" ); + _T("calling wxMutexGuiLeave() without entering it first?") ); s_nWaitingForGui--; @@ -807,7 +813,7 @@ void WXDLLEXPORT wxMutexGuiLeave() void WXDLLEXPORT wxMutexGuiLeaveOrEnter() { wxASSERT_MSG( wxThread::IsMain(), - "only main thread may call wxMutexGuiLeaveOrEnter()!" ); + _T("only main thread may call wxMutexGuiLeaveOrEnter()!") ); wxCriticalSectionLocker enter(*s_critsectWaitingForGui);