Inside and Out…

An attempt to understand technology better…

Archive for July, 2004

..and ThreadPool.GetMinThreads

Posted by Gaurav Khanna on July 25, 2004

And I am finally done with extending the Rotor’s ThreadPool class. Finished implementing the GetMinThreads method.

Download the source code from http://www.wintoolzone.com/showpage.aspx?url=rotor.aspx.

Posted in CLR, Development, Downloads, Rotor | Leave a Comment »

Rotor – SetMaxThreads, SetMinThreads

Posted by Gaurav Khanna on July 22, 2004

Just finished extending Rotor’s ThreadPool class to support SetMaxThreads and SetMinThreads methods – to modify the extent of the threadpool maintained by the Rotor runtime – just like .NET FX 2.0 has it.

Will post the source code soon…meanwhile, here’s my implementation of SetMinThreadsInternal in Win32ThreadPool.cpp:

/************************************************************************/
// Will be used to set the minimum number of threads in the Rotor Threadpool
// Kumar Gaurav Khanna - 22-Jul-2004
BOOL ThreadpoolMgr::SetMinThreads(DWORD MinWorkerThreads, 
                                     DWORD MinIOCompletionThreads)
{

    if (IsInitialized())
    {
        BOOL result = FALSE;

        // 1) cannot have minimum worker thread limit <=0
        // 2) cannot have minimum worker thread limit equal to 
// or greater than the maximum worker thread limit if ((MinWorkerThreads > 0) && (MinWorkerThreads < MaxLimitTotalWorkerThreads)) { if (MinWorkerThreads <= (DWORD) MinLimitTotalWorkerThreads) { MinLimitTotalWorkerThreads = MinWorkerThreads; result = TRUE; } } return result; } if (InterlockedCompareExchange(&Initialization, 1, 0) == 0) { Initialize(); BOOL result = FALSE; if ((MinWorkerThreads > 0) && (MinWorkerThreads < MaxLimitTotalWorkerThreads)) { if (MinWorkerThreads <= (DWORD) MinLimitTotalWorkerThreads) { MinLimitTotalWorkerThreads = MinWorkerThreads; result = TRUE; } } Initialization = -1; return result; } else // someone else is initializing. Too late, return false { return FALSE; } }

Posted in CLR, Downloads, Rotor | Leave a Comment »