]> git.saurik.com Git - wxWidgets.git/commitdiff
Rename WXTHREAD_XXX_PRIORITY yo wxPRIORITY_XXX.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Jan 2013 02:10:07 +0000 (02:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Jan 2013 02:10:07 +0000 (02:10 +0000)
This will allow to reuse the same constants for the process priorities in an
upcoming commit.

See #14931.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
include/wx/thread.h
interface/wx/thread.h
samples/thread/thread.cpp
src/msw/thread.cpp
src/os2/thread.cpp
src/osx/carbon/thread.cpp
src/unix/threadpsx.cpp
tests/thread/misc.cpp

index 3e87cac57c5b7a36800e9b41b41c239c520f7a3c..fead515ffb154d6013bb6a00760ff72c808b706f 100644 (file)
@@ -3383,5 +3383,13 @@ typedef const void* WXWidget;
 
 #endif /* !wxUSE_NO_MANIFEST && _MSC_FULL_VER >= 140040130 */
 
+/* wxThread and wxProcess priorities */
+enum
+{
+    wxPRIORITY_MIN     = 0u,   /* lowest possible priority */
+    wxPRIORITY_DEFAULT = 50u,  /* normal priority */
+    wxPRIORITY_MAX     = 100u  /* highest possible priority */
+};
+
 #endif
     /*  _WX_DEFS_H_ */
index 1cc9857b6556d5dcb62646356fa31bb8e3bb325e..1a1d0c27b45155ad370360f40134d3a416f02411 100644 (file)
@@ -86,12 +86,12 @@ enum wxThreadWait
 #endif
 };
 
-// defines the interval of priority
+// Obsolete synonyms for wxPRIORITY_XXX for backwards compatibility-only
 enum
 {
-    WXTHREAD_MIN_PRIORITY      = 0u,
-    WXTHREAD_DEFAULT_PRIORITY  = 50u,
-    WXTHREAD_MAX_PRIORITY      = 100u
+    WXTHREAD_MIN_PRIORITY      = wxPRIORITY_MIN,
+    WXTHREAD_DEFAULT_PRIORITY  = wxPRIORITY_DEFAULT,
+    WXTHREAD_MAX_PRIORITY      = wxPRIORITY_MAX
 };
 
 // There are 2 types of mutexes: normal mutexes and recursive ones. The attempt
@@ -558,7 +558,8 @@ public:
     wxThreadError Resume();
 
     // priority
-        // Sets the priority to "prio": see WXTHREAD_XXX_PRIORITY constants
+        // Sets the priority to "prio" which must be in 0..100 range (see
+        // also wxPRIORITY_XXX constants).
         //
         // NB: the priority can only be set before the thread is created
     void SetPriority(unsigned int prio);
index 7be2745d133868d9a94cc8ad79d91fbb70c7d1fb..e97b4a024c56e144efbd102d7776584ca7eca467 100644 (file)
@@ -675,17 +675,6 @@ enum wxThreadError
     wxTHREAD_MISC_ERROR
 };
 
-/**
-   Defines the interval of priority
-*/
-enum
-{
-    WXTHREAD_MIN_PRIORITY      = 0u,
-    WXTHREAD_DEFAULT_PRIORITY  = 50u,
-    WXTHREAD_MAX_PRIORITY      = 100u
-};
-
-
 /**
     @class wxThread
 
@@ -1113,12 +1102,9 @@ public:
     static wxThreadIdType GetMainId();
 
     /**
-        Gets the priority of the thread, between zero and 100.
+        Gets the priority of the thread, between 0 (lowest) and 100 (highest).
 
-        The following priorities are defined:
-          - @b WXTHREAD_MIN_PRIORITY: 0
-          - @b WXTHREAD_DEFAULT_PRIORITY: 50
-          - @b WXTHREAD_MAX_PRIORITY: 100
+        @see SetPriority()
     */
     unsigned int GetPriority() const;
 
@@ -1234,13 +1220,15 @@ public:
     static bool SetConcurrency(size_t level);
 
     /**
-        Sets the priority of the thread, between 0 and 100.
+        Sets the priority of the thread, between 0 (lowest) and 100 (highest).
+
         It can only be set after calling Create() but before calling Run().
 
-        The following priorities are defined:
-          - @b WXTHREAD_MIN_PRIORITY: 0
-          - @b WXTHREAD_DEFAULT_PRIORITY: 50
-          - @b WXTHREAD_MAX_PRIORITY: 100
+        The following symbolic constants can be used in addition to raw
+        values in 0..100 range:
+          - ::wxPRIORITY_MIN: 0
+          - ::wxPRIORITY_DEFAULT: 50
+          - ::wxPRIORITY_MAX: 100
     */
     void SetPriority(unsigned int priority);
 
index a8529189ed49b7fff3c602d8ed86606dcde7917e..b6adc3846d123deb73f7fd9b93f2e4eefab7e9e8 100644 (file)
@@ -559,11 +559,11 @@ void MyFrame::OnStartThreads(wxCommandEvent& WXUNUSED(event) )
         // have the lowest priority, the second - the highest, all the rest
         // the normal one
         if ( n == 0 )
-            thr->SetPriority(WXTHREAD_MIN_PRIORITY);
+            thr->SetPriority(wxPRIORITY_MIN);
         else if ( n == 1 )
-            thr->SetPriority(WXTHREAD_MAX_PRIORITY);
+            thr->SetPriority(wxPRIORITY_MAX);
         else
-            thr->SetPriority(WXTHREAD_DEFAULT_PRIORITY);
+            thr->SetPriority(wxPRIORITY_DEFAULT);
 
         threads.Add(thr);
     }
index 5c94b6066a52687ec8ddf874cb76f6a4409ba4ea..0fee1a39e9f20b7b578efcb3ee14a5a28f48f0f7 100644 (file)
@@ -442,7 +442,7 @@ public:
         m_thread = thread;
         m_hThread = 0;
         m_state = STATE_NEW;
-        m_priority = WXTHREAD_DEFAULT_PRIORITY;
+        m_priority = wxPRIORITY_DEFAULT;
         m_nRef = 1;
     }
 
@@ -699,7 +699,7 @@ bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize)
         return false;
     }
 
-    if ( m_priority != WXTHREAD_DEFAULT_PRIORITY )
+    if ( m_priority != wxPRIORITY_DEFAULT )
     {
         SetPriority(m_priority);
     }
index d1ee5dc364a051a7a0b29c2ab7698cd04d3da9e9..830595af2a64133b3cc6f5a906d14ed077a23de0 100644 (file)
@@ -354,7 +354,7 @@ public:
     {
         m_hThread = 0;
         m_eState = STATE_NEW;
-        m_nPriority = WXTHREAD_DEFAULT_PRIORITY;
+        m_nPriority = wxPRIORITY_DEFAULT;
     }
 
     ~wxThreadInternal()
@@ -497,7 +497,7 @@ bool wxThreadInternal::Create( wxThread* pThread,
         return false;
     }
     m_hThread = tid;
-    if (m_nPriority != WXTHREAD_DEFAULT_PRIORITY)
+    if (m_nPriority != wxPRIORITY_DEFAULT)
     {
         SetPriority(m_nPriority);
     }
index 9b2573b6c049a247f175fd1c94f1323e335c17eb..e8ab4cd0fecfb67dc088d0710541900a7b539d56 100644 (file)
@@ -475,7 +475,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 ;
@@ -683,7 +683,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;
@@ -1110,8 +1110,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);
index de36955cda32ac2ce70ba3bb2b1fc2d0b36e5031..b04eb1d60d28460048a5285734417ab58270f46b 100644 (file)
@@ -954,7 +954,7 @@ wxThreadInternal::wxThreadInternal()
 {
     m_state = STATE_NEW;
     m_cancelled = false;
-    m_prio = WXTHREAD_DEFAULT_PRIORITY;
+    m_prio = wxPRIORITY_DEFAULT;
     m_threadId = 0;
     m_exitcode = 0;
 
@@ -1231,7 +1231,7 @@ wxThreadError wxThread::Create(unsigned int WXUNUSED_STACKSIZE(stackSize))
     }
     else if ( max_prio == min_prio )
     {
-        if ( prio != WXTHREAD_DEFAULT_PRIORITY )
+        if ( prio != wxPRIORITY_DEFAULT )
         {
             // notify the programmer that this doesn't work here
             wxLogWarning(_("Thread priority setting is ignored."));
@@ -1320,8 +1320,7 @@ wxThreadError wxThread::Run()
 
 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);
@@ -1347,8 +1346,7 @@ void wxThread::SetPriority(unsigned int prio)
             //
             // FIXME this is not true for 2.6!!
 
-            // map wx priorites WXTHREAD_MIN_PRIORITY..WXTHREAD_MAX_PRIORITY
-            // to Unix priorities 20..-20
+            // map wx priorites 0..100 to Unix priorities 20..-20
             if ( setpriority(PRIO_PROCESS, 0, -(2*(int)prio)/5 + 20) == -1 )
             {
                 wxLogError(_("Failed to set thread priority %d."), prio);
index 83a63a1ac40efcab0182144d0bf6952ec03df93e..ecdf07df450310f85bead7ee80a1c5666d01ea25 100644 (file)
@@ -257,8 +257,8 @@ void MiscThreadTestCase::TestDetached()
         threads[n] = new MyDetachedThread(10, 'A' + n);
     }
 
-    threads[0]->SetPriority(WXTHREAD_MIN_PRIORITY);
-    threads[1]->SetPriority(WXTHREAD_MAX_PRIORITY);
+    threads[0]->SetPriority(wxPRIORITY_MIN);
+    threads[1]->SetPriority(wxPRIORITY_MAX);
 
     for ( n = 0; n < nThreads; n++ )
     {