]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/thread.cpp
extracted duplicated code from src/*/data.cpp in a common file
[wxWidgets.git] / src / msw / thread.cpp
index 2180ddd994e8a548c97498fb39de7e8eb51b61aa..cf2353b6157b7d5f7386936d10f2346c221490a6 100644 (file)
@@ -174,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
@@ -243,7 +245,7 @@ wxMutexError wxMutexInternal::Unlock()
 {
     if ( !::ReleaseMutex(m_mutex) )
     {
-        wxLogLastError(_("ReleaseMutex()"));
+        wxLogLastError(_T("ReleaseMutex()"));
 
         return wxMUTEX_MISC_ERROR;
     }
@@ -272,6 +274,8 @@ public:
 
 private:
     HANDLE m_semaphore;
+
+    DECLARE_NO_COPY_CLASS(wxSemaphoreInternal)
 };
 
 wxSemaphoreInternal::wxSemaphoreInternal(int initialcount, int maxcount)
@@ -536,6 +540,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)
@@ -965,30 +971,8 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
 
     HANDLE hThread = m_internal->GetHandle();
 
-       // Check if thread is really still running.  There is a
-       // race condition in WinThreadStart between the time the
-       // m_internal->m_state is set to STATE_EXITED and the win32
-       // thread actually exits.  It can be flagged as STATE_EXITED
-       // and then we don't wait for it to exit.  This will cause
-       // GetExitCodeThread to return STILL_ACTIVE.
-       if ( !isRunning )
-       {
-               if ( !IsRunning() )
-               {
-                       if ( ::GetExitCodeThread(hThread, (LPDWORD)&rc) )
-                       {
-                               if ((DWORD)rc == STILL_ACTIVE)
-                                       isRunning = TRUE;
-                       }
-               }                                                                                                               
-               else
-               {
-                       isRunning = TRUE;
-               }
-       }
-
-    // does it still run?
-    if ( isRunning )
+    // does is still run?
+    if ( isRunning || IsRunning() )
     {
         if ( IsMain() )
         {
@@ -1044,24 +1028,13 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
                     break;
 
                 case WAIT_OBJECT_0 + 1:
+                    // new message arrived, process it
+                    if ( !wxTheApp->DoMessage() )
                     {
-                        MSG    peekMsg;
-                        // Check if a new message has really arrived.
-                        // MsgWaitForMultipleObjects can indicate that a message
-                        // is ready for processing, but this message may be sucked
-                        // up by GetMessage and then GetMessage will hang and not
-                        // allow us to process the actual thread exit event.
-                        if (::PeekMessage(&peekMsg, (HWND) NULL, 0, 0, PM_NOREMOVE))
-                        {
-                            // new message arrived, process it
-                            if ( !wxTheApp->DoMessage() )
-                            {
-                                // WM_QUIT received: kill the thread
-                                Kill();
-                                                            
-                                return wxTHREAD_KILLED;
-                            }
-                        }
+                        // WM_QUIT received: kill the thread
+                        Kill();
+
+                        return wxTHREAD_KILLED;
                     }
                     break;