Class CSocketThreadManager::
GetMostAvailableThread()
Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: GetIndexByHWNDNext page: GetWindowHandle    Show member index
Private Function Declared in:
SocketThreadManager.h

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

int GetMostAvailableThread() const;

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

Get the freeiest thread

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

try
{
    //Start position
    int iStartPosition;
    iStartPosition=1;

    int iIndex;
    iIndex=0;

    //Enter the CS
    CCriticalAutoRelease aRelease(m_pCSection);

    //Check for freezing
    while (m_pThreadData[iIndex].bFreeze &&
           iIndex<m_ulThreadCount)
    {
        //Release the freeze
        m_pThreadData[iIndex].bFreeze=FALSE;

        ++iIndex;
        ++iStartPosition;
    }

    //Check we aren't in the end
    if (iIndex==m_ulThreadCount)
        return GetMostAvailableThread();

    //Start searching the threads
    for (int iCounter=iStartPosition;iCounter<m_ulThreadCount;++iCounter)
        //Check is it larger
        if (m_pThreadData[iCounter].iSocketCount+m_pThreadData[iCounter].iTimeoutCount<
            m_pThreadData[iIndex].iSocketCount+m_pThreadData[iIndex].iTimeoutCount &&
            m_pThreadData[iCounter].pThread->GetThreadID())
            //Check if is freezed
            if (m_pThreadData[iCounter].bFreeze)
                //Release the freeze
                m_pThreadData[iCounter].bFreeze=FALSE;
            else
                //Set the new index
                iIndex=iCounter;

    //Return the value
    return iIndex+1;
}
ERROR_HANDLER_RETURN("GetMostAvailableThread",0)

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

Class Overview Class Overview  |  Public base class CErrorHandler  |  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.