ultimatepp/uppsrc/Draw/DrawLock.cpp
cxl 6df29eb3bd CtrlCore, Draw: New headless draw
git-svn-id: svn://ultimatepp.org/upp/trunk@1374 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-07-06 22:01:01 +00:00

45 lines
567 B
C++

#include "Draw.h"
NAMESPACE_UPP
#ifdef _MULTITHREADED
static StaticMutex sGLock;
static thread__ int sGLockLevel = 0;
void EnterGMutex()
{
if(sGLockLevel++ == 0)
sGLock.Enter();
}
void EnterGMutex(int n)
{
if(n > 0) {
if(sGLockLevel == 0)
sGLock.Enter();
sGLockLevel += n;
}
}
void LeaveGMutex()
{
ASSERT(sGLockLevel > 0);
if(--sGLockLevel == 0)
sGLock.Leave();
}
int LeaveGMutexAll()
{
int q = sGLockLevel;
if(q) {
sGLock.Leave();
sGLockLevel = 0;
}
return q;
}
#endif
END_UPP_NAMESPACE