]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/thread.cpp
Make public headers compatible with Objective-C++ with ARC.
[wxWidgets.git] / src / osx / carbon / thread.cpp
index 9b2573b6c049a247f175fd1c94f1323e335c17eb..dcb7bd778a48dc0a503bc8d764fceb91a38a43e8 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Original from Wolfram Gloger/Guilhem Lavaux/Vadim Zeitlin
 // Modified by: Aj Lavin, Stefan Csomor
 // Created:     04/22/98
-// RCS-ID:      $Id$
 // Copyright:   (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998),
 //                  Vadim Zeitlin (1999), Stefan Csomor (2000)
 // Licence:     wxWindows licence
@@ -475,7 +474,7 @@ public:
     {
         m_tid = kInvalidID;
         m_state = STATE_NEW;
-        m_prio = WXTHREAD_DEFAULT_PRIORITY;
+        m_prio = wxPRIORITY_DEFAULT;
         m_notifyQueueId = kInvalidID;
         m_exitcode = 0;
         m_cancelled = false ;
@@ -624,7 +623,7 @@ OSStatus wxThreadInternal::MacThreadStart(void *parameter)
 
     if ( !dontRunAtAll )
     {
-        pthread->m_exitcode = thread->Entry();
+        pthread->m_exitcode = thread->CallEntry();
 
         {
             wxCriticalSectionLocker lock(thread->m_critsect);
@@ -656,6 +655,9 @@ bool wxThreadInternal::Create( wxThread *thread, unsigned int stackSize )
     wxASSERT_MSG( m_state == STATE_NEW && !m_tid,
                     wxT("Create()ing thread twice?") );
 
+    if ( thread->IsDetached() )
+        Detach();
+
     OSStatus err = noErr;
     m_thread = thread;
 
@@ -683,7 +685,7 @@ bool wxThreadInternal::Create( wxThread *thread, unsigned int stackSize )
         return false;
     }
 
-    if ( m_prio != WXTHREAD_DEFAULT_PRIORITY )
+    if ( m_prio != wxPRIORITY_DEFAULT )
         SetPriority( m_prio );
 
     return true;
@@ -868,13 +870,9 @@ wxThreadError wxThread::Create( unsigned int stackSize )
 {
     wxCriticalSectionLocker lock(m_critsect);
 
-    if ( m_isDetached )
-        m_internal->Detach() ;
-
     if ( !m_internal->Create(this, stackSize) )
     {
         m_internal->SetState( STATE_EXITED );
-
         return wxTHREAD_NO_RESOURCE;
     }
 
@@ -885,6 +883,17 @@ wxThreadError wxThread::Run()
 {
     wxCriticalSectionLocker lock(m_critsect);
 
+    // Create the thread if it wasn't created yet with an explicit
+    // Create() call:
+    if ( m_internal->GetId() == kInvalidID )
+    {
+        if ( !m_internal->Create(this, stackSize) )
+        {
+            m_internal->SetState( STATE_EXITED );
+            return wxTHREAD_NO_RESOURCE;
+        }
+    }
+
     wxCHECK_MSG( m_internal->GetId(), wxTHREAD_MISC_ERROR,
                  wxT("must call wxThread::Create() first") );
 
@@ -1110,8 +1119,7 @@ bool wxThread::TestDestroy()
 
 void wxThread::SetPriority(unsigned int prio)
 {
-    wxCHECK_RET( ((int)WXTHREAD_MIN_PRIORITY <= (int)prio) &&
-                 ((int)prio <= (int)WXTHREAD_MAX_PRIORITY),
+    wxCHECK_RET( wxPRIORITY_MIN <= prio && prio <= wxPRIORITY_MAX,
                  wxT("invalid thread priority") );
 
     wxCriticalSectionLocker lock(m_critsect);