From: Vadim Zeitlin Date: Sun, 20 Jan 2013 02:10:07 +0000 (+0000) Subject: Rename WXTHREAD_XXX_PRIORITY yo wxPRIORITY_XXX. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/90e95e61175953284a40c73f1d62ccc18ef4c748 Rename WXTHREAD_XXX_PRIORITY yo wxPRIORITY_XXX. 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 --- diff --git a/include/wx/defs.h b/include/wx/defs.h index 3e87cac57c..fead515ffb 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -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_ */ diff --git a/include/wx/thread.h b/include/wx/thread.h index 1cc9857b65..1a1d0c27b4 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -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); diff --git a/interface/wx/thread.h b/interface/wx/thread.h index 7be2745d13..e97b4a024c 100644 --- a/interface/wx/thread.h +++ b/interface/wx/thread.h @@ -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); diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index a8529189ed..b6adc3846d 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -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); } diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 5c94b6066a..0fee1a39e9 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -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); } diff --git a/src/os2/thread.cpp b/src/os2/thread.cpp index d1ee5dc364..830595af2a 100644 --- a/src/os2/thread.cpp +++ b/src/os2/thread.cpp @@ -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); } diff --git a/src/osx/carbon/thread.cpp b/src/osx/carbon/thread.cpp index 9b2573b6c0..e8ab4cd0fe 100644 --- a/src/osx/carbon/thread.cpp +++ b/src/osx/carbon/thread.cpp @@ -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); diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index de36955cda..b04eb1d60d 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -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); diff --git a/tests/thread/misc.cpp b/tests/thread/misc.cpp index 83a63a1ac4..ecdf07df45 100644 --- a/tests/thread/misc.cpp +++ b/tests/thread/misc.cpp @@ -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++ ) {