Obtain a read lock on a resource. This is only spin if there is a write lock in place.

Return TypeFunction nameArguments
hzEcodehzLockRWD::LockRead(int32_t,)

Declared in file: hzLock.h
Defined in file : hzLock.cpp

Function Logic:

0:START 1:unknown 2:Return E_OK 3:tid 4:unknown 5:Return E_NOTFOUND 6:unknown 7:items 8:unknown 9:unknown 10:Return E_NOTFOUND 11:unknown 12:unknown 13:Return E_OK

Function body:

hzEcode hzLockRWD::LockRead (int32_t nTries)
{
   //  Obtain a read lock on a resource. This is only spin if there is a write lock in place.
   //  
   //  Arguments: 1) timout The timeout limit (limit of retries in thousands)
   //  
   //  Returns: E_NOTFOUND The previous thread with write access killed the lock (should be because it deleted the applicable resource)
   //     E_TIMEOUT The thread holding write access has held the lock for too long
   //     E_OK  Write access granted
   _hzfunc("hzLockRWD::LockRead") ;
   uint32_t    cont ;      //  Contention or spin count
   uint32_t    tid ;       //  Thread id
   if (!_hzGlobal_MT)
       return E_OK ;
   tid = pthread_self() ;
   if (m_lockval == 0xffffffff)
       return E_NOTFOUND ;
   if (m_lockval == tid)
       Fatal("Attempt by thread %u to re-lock address %p\n", tid, &m_lockval) ;
   for (cont = 0; m_lockval ; cont++)
   {
       if (m_lockval == 0xffffffff)
           return E_NOTFOUND ;
       if (!m_lockval)
           break ;
   }
   while (__sync_add_and_fetch(&m_counter, 1));
   return E_OK ;
}