]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/thread.cpp
make wxSelectDispatcher ctor public, it can be useful to create it in places other...
[wxWidgets.git] / src / os2 / thread.cpp
index c36201e2c9d95d2ffa3cfd939fa175a9c189063f..253fb2143acf8192672efa69af29b135ca0b81bc 100644 (file)
@@ -6,14 +6,9 @@
 // Created:     04/22/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Stefan Neis (2003)
 // Created:     04/22/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Stefan Neis (2003)
-//
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "thread.h"
-#endif
-
 // ----------------------------------------------------------------------------
 // headers
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // headers
 // ----------------------------------------------------------------------------
 
 #if wxUSE_THREADS
 
 
 #if wxUSE_THREADS
 
-#include <stdio.h>
+#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/apptrait.h"
-#include "wx/module.h"
-#include "wx/intl.h"
 #include "wx/utils.h"
 #include "wx/utils.h"
-#include "wx/log.h"
-#include "wx/thread.h"
+
+#include <stdio.h>
 
 #define INCL_DOSSEMAPHORES
 #define INCL_DOSPROCESS
 
 #define INCL_DOSSEMAPHORES
 #define INCL_DOSPROCESS
@@ -97,7 +96,8 @@ public:
     bool IsOk() const { return m_vMutex != NULL; }
 
     wxMutexError Lock() { return LockTimeout(SEM_INDEFINITE_WAIT); }
     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:
     wxMutexError Unlock();
 
 private:
@@ -128,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;
 wxMutexError wxMutexInternal::LockTimeout(ULONG ulMilliseconds)
 {
     APIRET                          ulrc;
@@ -137,6 +145,7 @@ wxMutexError wxMutexInternal::LockTimeout(ULONG ulMilliseconds)
     switch (ulrc)
     {
         case ERROR_TIMEOUT:
     switch (ulrc)
     {
         case ERROR_TIMEOUT:
+            return wxMUTEX_TIMEOUT;
         case ERROR_TOO_MANY_SEM_REQUESTS:
             return wxMUTEX_BUSY;
 
         case ERROR_TOO_MANY_SEM_REQUESTS:
             return wxMUTEX_BUSY;
 
@@ -385,11 +394,9 @@ private:
     unsigned int                    m_nPriority;  // thread priority in "wx" units
 };
 
     unsigned int                    m_nPriority;  // thread priority in "wx" units
 };
 
-void wxThreadInternal::OS2ThreadStart(
-  void * pParam
-)
+void wxThreadInternal::OS2ThreadStart( void * pParam )
 {
 {
-    DWORD                           dwRet;
+    DWORD dwRet;
     bool bWasCancelled;
 
     wxThread *pThread = (wxThread *)pParam;
     bool bWasCancelled;
 
     wxThread *pThread = (wxThread *)pParam;
@@ -978,7 +985,7 @@ void WXDLLEXPORT wxWakeUpMainThread()
 #endif
 }
 
 #endif
 }
 
-void WXDLLEXPORT wxMutexGuiEnter()
+void wxMutexGuiEnterImpl()
 {
     // this would dead lock everything...
     wxASSERT_MSG( !wxThread::IsMain(),
 {
     // this would dead lock everything...
     wxASSERT_MSG( !wxThread::IsMain(),
@@ -1000,7 +1007,7 @@ void WXDLLEXPORT wxMutexGuiEnter()
     gs_pCritsectGui->Enter();
 }
 
     gs_pCritsectGui->Enter();
 }
 
-void WXDLLEXPORT wxMutexGuiLeave()
+void wxMutexGuiLeaveImpl()
 {
     wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui);
 
 {
     wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui);