CRITICAL SECTION Won't Compile!
Here's my code; It errors out wanting to add a ; before the CArray
declaration:
error C2143: syntax error : missing ';' before '<'
Also, why did you choose a SIZE_T ( a double ) for the loop?
//critical section to deal with the avaiable timers
class TimerStatus{
public:
TimerStatus(int n){InitializeCriticalSection(&lock);Busy.SetSize(n);}
virtual ~TimerStatus(){DeleteCriticalSection(&lock);}
void FreeTimer(int i)
{
EnterCriticalSection(&lock);
Busy[i] = FALSE;
LeaveCriticalSection(&lock);
}//free up a timer
int AllocateTimer()
{
int result = -1;//-1 means no timer avaiable
EnterCriticalSection(&lock);
for(SIZE_T i = 0;i<Busy.GetSize();i++)
if(!Busy[i])
{
Busy[i] = TRUE;
result = i;
break;
}
LeaveCriticalSection(&lock);
return result;
}
protected:
CArray<BOOL,BOOL> Busy;
CRITICAL_SECTION lock;
};
TimerStatus TStatus(3);
-----------------
www.Newsgroup-Binaries.com - *Completion*Retention*Speed*
Access your favorite newsgroups from home or on the road
-----------------