![]() |
LockRead() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Public Function |
Declared in: Win32ReadWriteLock.h |
virtual BOOL LockRead( unsigned long ulMSTimeout=INFINITE);
Lock for reading Returns TRUE for timeout
//First lock the mutex and check the read flag CMutexAutoRelease aRelease(m_pMutex,TRUE); //Check the flag if (m_bEscalation || m_bWriter) //Can't lock return FALSE; //Check if we will be locked ? if (m_iReaders==GetMaximumReaders()) { //Release the lock and try to get it aRelease.Release(); //Lock the semaphore if (m_pSemaphore->Aquire(ulMSTimeout)) return FALSE; else { //Relock it aRelease.Aquire(); //Check if there are writers ? if (m_bEscalation || m_bWriter) { //So soon ? //Release what we got m_pSemaphore->Release(); //Exit return FALSE; } else //Increase the count ++m_iReaders; } } else if (m_pSemaphore->Aquire(ulMSTimeout)) return FALSE; else //Increase the semaphore and our count ++m_iReaders; //Done return TRUE;
![]() |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |