changed un-inlined code to avoid bogus VC++ level 4 warnings.
added support for more win32 thread priorities.
This commit is contained in:
parent
cda243ac76
commit
024f76c909
|
@ -117,3 +117,18 @@ bool CThread::operator!=(const CThread& thread) const
|
||||||
{
|
{
|
||||||
return (m_rep != thread.m_rep);
|
return (m_rep != thread.m_rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// CThreadMaskCancel
|
||||||
|
//
|
||||||
|
|
||||||
|
CThreadMaskCancel::CThreadMaskCancel() : m_old(CThread::enableCancel(false))
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
CThreadMaskCancel::~CThreadMaskCancel()
|
||||||
|
{
|
||||||
|
CThread::enableCancel(m_old);
|
||||||
|
}
|
||||||
|
|
|
@ -125,8 +125,8 @@ private:
|
||||||
// disables cancellation in the c'tor and enables it in the d'tor.
|
// disables cancellation in the c'tor and enables it in the d'tor.
|
||||||
class CThreadMaskCancel {
|
class CThreadMaskCancel {
|
||||||
public:
|
public:
|
||||||
CThreadMaskCancel() : m_old(CThread::enableCancel(false)) { }
|
CThreadMaskCancel();
|
||||||
~CThreadMaskCancel() { CThread::enableCancel(m_old); }
|
~CThreadMaskCancel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_old;
|
bool m_old;
|
||||||
|
|
|
@ -534,11 +534,22 @@ bool CThreadRep::wait(CThreadRep* target, double timeout)
|
||||||
|
|
||||||
void CThreadRep::setPriority(int n)
|
void CThreadRep::setPriority(int n)
|
||||||
{
|
{
|
||||||
|
DWORD pClass = NORMAL_PRIORITY_CLASS;
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
switch (-n) {
|
switch (-n) {
|
||||||
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
|
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
|
||||||
|
case 2: n = THREAD_PRIORITY_HIGHEST; break;
|
||||||
|
default:
|
||||||
|
pClass = HIGH_PRIORITY_CLASS;
|
||||||
|
switch (-n - 3) {
|
||||||
|
case 0: n = THREAD_PRIORITY_LOWEST; break;
|
||||||
|
case 1: n = THREAD_PRIORITY_BELOW_NORMAL; break;
|
||||||
|
case 2: n = THREAD_PRIORITY_NORMAL; break;
|
||||||
|
case 3: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
|
||||||
default: n = THREAD_PRIORITY_HIGHEST; break;
|
default: n = THREAD_PRIORITY_HIGHEST; break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (n) {
|
switch (n) {
|
||||||
|
@ -548,6 +559,7 @@ void CThreadRep::setPriority(int n)
|
||||||
default: n = THREAD_PRIORITY_IDLE; break;
|
default: n = THREAD_PRIORITY_IDLE; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SetPriorityClass(m_thread, pClass);
|
||||||
SetThreadPriority(m_thread, n);
|
SetThreadPriority(m_thread, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue