]> git.saurik.com Git - wxWidgets.git/commitdiff
fixes return values of wxSemaphore::TryWait() and WaitTimeout() to behave as documented
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 12 Apr 2003 00:43:28 +0000 (00:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 12 Apr 2003 00:43:28 +0000 (00:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/thread.cpp
src/unix/threadpsx.cpp

index cf2353b6157b7d5f7386936d10f2346c221490a6..7c5a377d5e2b03eea56ac94e395c46d6161164ae 100644 (file)
@@ -267,7 +267,16 @@ 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();
@@ -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)"));
index 89bc5109f77cd4ec76c5f7b5d22bed64f35fbbb7..113c85a3b214e2d26e794f6e602ad9662b23c12b 100644 (file)
@@ -532,8 +532,17 @@ wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds)
             return wxSEMA_TIMEOUT;
         }
 
-        if ( m_cond.WaitTimeout(remainingTime) != wxCOND_NO_ERROR )
-            return wxSEMA_MISC_ERROR;
+        switch ( m_cond.WaitTimeout(remainingTime) )
+        {
+            case wxCOND_TIMEOUT:
+                return wxSEMA_TIMEOUT;
+
+            default:
+                return wxSEMA_MISC_ERROR;
+
+            case wxCOND_NO_ERROR:
+                ;
+        }
     }
 
     m_count--;