- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
void checklock(globalMemManager *c)
{
if (!c->isThread) return;
_voidint idl=c->isThread();
#ifdef THREADDEBUG
assert(idl!=0);
#endif
while (idl==0 && c->lock());
if (idl!=0) while (true) {
while (c->lockId()!=idl) {
c->canLeave()=idl;
}
if (c->lock()) break;
}
c->lock()=true;
}
void unlock(globalMemManager *c)
{
if (!c->isThread) return;
c->lock()=false;
#ifdef THREADDEBUG
assert(c->lockId()==c->isThread());
#endif
c->canLeave()=0;
c->lockId()=0;
}
void globalMemManager::manage()
{
if (!lock()) if (lockId()==0 && canLeave()!=0) {
if (!lock()) lock()=true;
lockId()=canLeave();
}
}
foxes 11.03.2016 09:05 # 0
kegdan 11.03.2016 09:38 # +1
foxes 11.03.2016 12:58 # 0