changed un-inlined code to avoid bogus VC++ level 4 warnings.

added support for more win32 thread priorities.
This commit is contained in:
crs 2002-05-22 16:55:05 +00:00
parent cda243ac76
commit 024f76c909
3 changed files with 30 additions and 3 deletions

View File

@ -117,3 +117,18 @@ bool CThread::operator!=(const CThread& thread) const
{
return (m_rep != thread.m_rep);
}
//
// CThreadMaskCancel
//
CThreadMaskCancel::CThreadMaskCancel() : m_old(CThread::enableCancel(false))
{
// do nothing
}
CThreadMaskCancel::~CThreadMaskCancel()
{
CThread::enableCancel(m_old);
}

View File

@ -125,8 +125,8 @@ private:
// disables cancellation in the c'tor and enables it in the d'tor.
class CThreadMaskCancel {
public:
CThreadMaskCancel() : m_old(CThread::enableCancel(false)) { }
~CThreadMaskCancel() { CThread::enableCancel(m_old); }
CThreadMaskCancel();
~CThreadMaskCancel();
private:
bool m_old;

View File

@ -534,10 +534,21 @@ bool CThreadRep::wait(CThreadRep* target, double timeout)
void CThreadRep::setPriority(int n)
{
DWORD pClass = NORMAL_PRIORITY_CLASS;
if (n < 0) {
switch (-n) {
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
default: n = THREAD_PRIORITY_HIGHEST; 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;
}
break;
}
}
else {
@ -548,6 +559,7 @@ void CThreadRep::setPriority(int n)
default: n = THREAD_PRIORITY_IDLE; break;
}
}
SetPriorityClass(m_thread, pClass);
SetThreadPriority(m_thread, n);
}