#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_ */
#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
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);
wxTHREAD_MISC_ERROR
};
-/**
- Defines the interval of priority
-*/
-enum
-{
- WXTHREAD_MIN_PRIORITY = 0u,
- WXTHREAD_DEFAULT_PRIORITY = 50u,
- WXTHREAD_MAX_PRIORITY = 100u
-};
-
-
/**
@class wxThread
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;
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);
// 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);
}
m_thread = thread;
m_hThread = 0;
m_state = STATE_NEW;
- m_priority = WXTHREAD_DEFAULT_PRIORITY;
+ m_priority = wxPRIORITY_DEFAULT;
m_nRef = 1;
}
return false;
}
- if ( m_priority != WXTHREAD_DEFAULT_PRIORITY )
+ if ( m_priority != wxPRIORITY_DEFAULT )
{
SetPriority(m_priority);
}
{
m_hThread = 0;
m_eState = STATE_NEW;
- m_nPriority = WXTHREAD_DEFAULT_PRIORITY;
+ m_nPriority = wxPRIORITY_DEFAULT;
}
~wxThreadInternal()
return false;
}
m_hThread = tid;
- if (m_nPriority != WXTHREAD_DEFAULT_PRIORITY)
+ if (m_nPriority != wxPRIORITY_DEFAULT)
{
SetPriority(m_nPriority);
}
{
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 ;
return false;
}
- if ( m_prio != WXTHREAD_DEFAULT_PRIORITY )
+ if ( m_prio != wxPRIORITY_DEFAULT )
SetPriority( m_prio );
return true;
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);
{
m_state = STATE_NEW;
m_cancelled = false;
- m_prio = WXTHREAD_DEFAULT_PRIORITY;
+ m_prio = wxPRIORITY_DEFAULT;
m_threadId = 0;
m_exitcode = 0;
}
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."));
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);
//
// 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);
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++ )
{