Return Type | Function name | Arguments |
---|---|---|
hzEcode | hzLockS::Lock | (int,) |
Declared in file: hzLock.h
Defined in file : hzLock.cpp
Function Logic:
Function body:
hzEcode hzLockS::Lock (int nTries) { uint32_t cont ; uint32_t tries ; uint32_t tid ; uint32_t limit ; if (!_hzGlobal_MT) return E_OK ; tid = pthread_self() ; limit = nTries < 0? 0xfffffffe:nTries*1000; if (m_lockval == tid) Fatal("hzLockS::hzLockS. Attempt by thread %u to re-lock address %p\n", tid, &m_lockval) ; for (tries = cont = 0;;) { if (m_lockval == 0xffffffff) return E_NOTFOUND ; if (m_lockval) { cont++ ; continue ; } if (!__sync_val_compare_and_swap(&m_lockval, 0,tid)) { if (m_lockval == tid) break ; } tries++ ; if (tries > limit) return E_TIMEOUT ; } m_lockval = tid ; return E_OK ; }