ultimatepp/uppsrc/Draw/DrawLock.cpp
cxl 45599b5f26 CtrlCore: Massive fix of MT, Draw: Fixed DrawingDraw::Create for case when tehere are some data in DrawingDraw
git-svn-id: svn://ultimatepp.org/upp/trunk@1506 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-08-13 13:40:54 +00:00

51 lines
688 B
C++

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