fixes return values of wxSemaphore::TryWait() and WaitTimeout() to behave as documented
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -267,7 +267,16 @@ public:
|
|||||||
bool IsOk() const { return m_semaphore != NULL; }
|
bool IsOk() const { return m_semaphore != NULL; }
|
||||||
|
|
||||||
wxSemaError Wait() { return WaitTimeout(INFINITE); }
|
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 WaitTimeout(unsigned long milliseconds);
|
||||||
|
|
||||||
wxSemaError Post();
|
wxSemaError Post();
|
||||||
@@ -321,7 +330,7 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds)
|
|||||||
return wxSEMA_NO_ERROR;
|
return wxSEMA_NO_ERROR;
|
||||||
|
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
return wxSEMA_BUSY;
|
return wxSEMA_TIMEOUT;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxLogLastError(_T("WaitForSingleObject(semaphore)"));
|
wxLogLastError(_T("WaitForSingleObject(semaphore)"));
|
||||||
|
@@ -532,8 +532,17 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds)
|
|||||||
return wxSEMA_TIMEOUT;
|
return wxSEMA_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_cond.WaitTimeout(remainingTime) != wxCOND_NO_ERROR )
|
switch ( m_cond.WaitTimeout(remainingTime) )
|
||||||
return wxSEMA_MISC_ERROR;
|
{
|
||||||
|
case wxCOND_TIMEOUT:
|
||||||
|
return wxSEMA_TIMEOUT;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return wxSEMA_MISC_ERROR;
|
||||||
|
|
||||||
|
case wxCOND_NO_ERROR:
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_count--;
|
m_count--;
|
||||||
|
Reference in New Issue
Block a user