Return Type | Function name | Arguments |
---|---|---|
hzEcode | hzLockRW::LockWrite | (int,) |
Declared in file: hzLock.h
Defined in file : hzLock.cpp
Function Logic:
Function body:
hzEcode hzLockRW::LockWrite (int nTries) { _hzfunc("hzLockRW::LockWrite") ; 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("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 ; } for (; m_counter ; cont++) ; return E_OK ; }