This one was particularly nasty because Windows also defines a DWORD, but in Windows it is an unsigned long, not an unsigned int so changing types caused type conflicts and not all could be removed. Those referring to the Windows type have to be kept, fortunately they are mostly in the Win32 directory, with a handful of exceptions elsewhere.
57 lines
922 B
C++
57 lines
922 B
C++
// Wraps a Windows critical section object.
|
|
|
|
#ifndef _WINNT_
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
class FInternalCriticalSection
|
|
{
|
|
public:
|
|
FInternalCriticalSection()
|
|
{
|
|
InitializeCriticalSection(&CritSec);
|
|
}
|
|
~FInternalCriticalSection()
|
|
{
|
|
DeleteCriticalSection(&CritSec);
|
|
}
|
|
void Enter()
|
|
{
|
|
EnterCriticalSection(&CritSec);
|
|
}
|
|
void Leave()
|
|
{
|
|
LeaveCriticalSection(&CritSec);
|
|
}
|
|
#if 0
|
|
// SDL has no equivalent functionality, so better not use it on Windows.
|
|
bool TryEnter()
|
|
{
|
|
return TryEnterCriticalSection(&CritSec) != 0;
|
|
}
|
|
#endif
|
|
private:
|
|
CRITICAL_SECTION CritSec;
|
|
};
|
|
|
|
|
|
FInternalCriticalSection *CreateCriticalSection()
|
|
{
|
|
return new FInternalCriticalSection();
|
|
}
|
|
|
|
void DeleteCriticalSection(FInternalCriticalSection *c)
|
|
{
|
|
delete c;
|
|
}
|
|
|
|
void EnterCriticalSection(FInternalCriticalSection *c)
|
|
{
|
|
c->Enter();
|
|
}
|
|
|
|
void LeaveCriticalSection(FInternalCriticalSection *c)
|
|
{
|
|
c->Leave();
|
|
}
|