X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/76a6e80383f1485b4d0e11ff2c5de632e46bc36e..f5c479ccfc9adf26d4cc8515bfbdb3230bd934b6:/src/unix/threadpsx.cpp diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index ae471b8d6b..e8aad25e50 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -37,6 +37,7 @@ #include "wx/intl.h" #include "wx/dynarray.h" #include "wx/timer.h" +#include "wx/stopwatch.h" #include #include @@ -113,7 +114,7 @@ WX_DEFINE_ARRAY(wxThread *, wxArrayThread); static wxArrayThread gs_allThreads; // the id of the main thread -static pthread_t gs_tidMain; +static pthread_t gs_tidMain = (pthread_t)-1; // the key for the pointer to the associated wxThread object static pthread_key_t gs_keySelf; @@ -678,7 +679,7 @@ public: private: pthread_t m_threadId; // id of the thread wxThreadState m_state; // see wxThreadState enum - int m_prio; // in wxWindows units: from 0 to 100 + int m_prio; // in wxWidgets units: from 0 to 100 // this flag is set when the thread should terminate bool m_cancelled; @@ -957,7 +958,7 @@ wxThread *wxThread::This() bool wxThread::IsMain() { - return (bool)pthread_equal(pthread_self(), gs_tidMain); + return (bool)pthread_equal(pthread_self(), gs_tidMain) || gs_tidMain == (pthread_t)-1; } void wxThread::Yield() @@ -969,7 +970,7 @@ void wxThread::Yield() void wxThread::Sleep(unsigned long milliseconds) { - wxUsleep(milliseconds); + wxMilliSleep(milliseconds); } int wxThread::GetCPUCount() @@ -1483,6 +1484,12 @@ void wxThread::Exit(ExitCode status) // only call one thread function at a time :-( DeleteThread(this); } + else + { + m_critsect.Enter(); + m_internal->SetState(STATE_EXITED); + m_critsect.Leave(); + } // terminate the thread (pthread_exit() never returns) pthread_exit(status);