fixed CriticalSectionLocker (thanks to Nukem)

This commit is contained in:
Mr. eXoDia 2014-12-22 23:22:59 +01:00
parent 29f8973700
commit f04f96e83d
2 changed files with 7 additions and 1 deletions

View File

@ -30,20 +30,25 @@ CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
{
CriticalSectionInitializeLocks(); //initialize critical sections
gLock = lock;
EnterCriticalSection(&locks[gLock]);
Locked = true;
}
CriticalSectionLocker::~CriticalSectionLocker()
{
if(Locked)
LeaveCriticalSection(&locks[gLock]);
}
void CriticalSectionLocker::unlock()
{
Locked = false;
LeaveCriticalSection(&locks[gLock]);
}
void CriticalSectionLocker::relock()
{
EnterCriticalSection(&locks[gLock]);
Locked = true;
}

View File

@ -25,6 +25,7 @@ public:
private:
CriticalSectionLock gLock;
bool Locked;
};
#endif //_GLOBAL_ENGINE_THREADING_H