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
This commit is contained in:
Vadim Zeitlin 2013-01-20 02:10:07 +00:00
parent f2e763d7f1
commit 90e95e6117
9 changed files with 39 additions and 45 deletions

View 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_ */

View 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);

View 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);

View 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);
}

View 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);
}

View 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);
}

View 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);

View 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);

View 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++ )
{