Class CWin32ReadWriteLock::
LockRead()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: EscalateNext page: LockWrite    Show member index
Public Function Declared in:
Win32ReadWriteLock.h

'Declaration' icon -- Shortcut to top of page. Declaration

virtual BOOL LockRead(
    unsigned long ulMSTimeout=INFINITE);

'Description' icon -- Shortcut to top of page. Description

Lock for reading Returns TRUE for timeout

'Function Body' icon -- Shortcut to top of page. Function Body

//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;

'See Also' icon -- Shortcut to top of page. See Also

Class Overview Class Overview  |  Public base class CGenericReadWriteLock  |  Hierarchy Chart Hierarchy Chart


Get Surveyor!This web site was generated using Surveyor V4.50.811.1.  Click here for more information. Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003.