mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlCore: TryEnterGuiMutex
git-svn-id: svn://ultimatepp.org/upp/trunk@11908 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2347bfd911
commit
3dbc3b4e31
2 changed files with 11 additions and 0 deletions
|
|
@ -42,6 +42,7 @@ INITIALIZE(CtrlCore)
|
|||
|
||||
#ifdef _MULTITHREADED
|
||||
void EnterGuiMutex();
|
||||
bool TryEnterGuiMutex();
|
||||
void LeaveGuiMutex();
|
||||
|
||||
int LeaveGuiMutexAll();
|
||||
|
|
@ -51,6 +52,7 @@ bool ThreadHasGuiLock();
|
|||
#else
|
||||
inline void EnterGuiMutex() {}
|
||||
inline void LeaveGuiMutex() {}
|
||||
inline bool TryEnterGuiMutex() { return true; }
|
||||
|
||||
inline int LeaveGuiMutexAll() { return 0; }
|
||||
inline void EnterGuiMutex(int) {}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,15 @@ void EnterGuiMutex(int n)
|
|||
LLOG("EnterGuiMutex " << sGLockLevel << ' ' << IsMainThread());
|
||||
}
|
||||
|
||||
bool TryEnterGuiMutex()
|
||||
{
|
||||
if(sGLockLevel == 0 && sGLock.TryEnter()) {
|
||||
sGLockLevel++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LeaveGuiMutex()
|
||||
{
|
||||
LLOG(">LeaveGuiMutex " << sGLockLevel << ' ' << IsMainThread());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue