mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-17 06:06:00 -06:00
41 lines
566 B
C++
41 lines
566 B
C++
#include "Draw.h"
|
|
|
|
NAMESPACE_UPP
|
|
|
|
static StaticMutex sGuiLock;
|
|
|
|
static thread__ int sGuiLockLevel = 0;
|
|
|
|
void EnterGuiMutex()
|
|
{
|
|
if(sGuiLockLevel++ == 0)
|
|
sGuiLock.Enter();
|
|
}
|
|
|
|
void EnterGuiMutex(int n)
|
|
{
|
|
if(n > 0) {
|
|
if(sGuiLockLevel == 0)
|
|
sGuiLock.Enter();
|
|
sGuiLockLevel += n;
|
|
}
|
|
}
|
|
|
|
void LeaveGuiMutex()
|
|
{
|
|
ASSERT(sGuiLockLevel > 0);
|
|
if(--sGuiLockLevel == 0)
|
|
sGuiLock.Leave();
|
|
}
|
|
|
|
int LeaveGuiMutexAll()
|
|
{
|
|
int q = sGuiLockLevel;
|
|
if(q) {
|
|
sGuiLock.Leave();
|
|
sGuiLockLevel = 0;
|
|
}
|
|
return q;
|
|
}
|
|
|
|
END_UPP_NAMESPACE
|