Class CThreadPool Base ClassesData ItemsConstructorsDestructorsFunctionsCustom CodeGo to hierarchy chart    Prev page: Custom Code in Source After IncludesNext page: m_aJobList    Show member index
Class Declared in:
ThreadPool.h

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

Copyright (c) 2000-2003 Barak Weichselbaum <barak@komodia.com> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Contact info:

Site:                  http://www.komodia.com Main contact:          barak@komodia.com For custom projects, consulting, or other paid services:         sales@komodia.com

Hierarchy Chart Hierarchy Chart

'Base Classes' icon -- Shortcut to top of page. Base Classes

Public base class CErrorHandler

'Data Items' icon -- Shortcut to top of page. Data Items

Private data JobVector m_aJobList Our vector
Private data BOOL m_bDrop Do we drop extra data ?
Private data BOOL m_bInitialized Is the pool initialized
Private data DWORD m_dwSleepInterval Sleep interval for the semaphore
Private data int m_iMaxJobsPending Max jobs pending
Private data int m_iRunningThreads Our running thread count
Private data CGenericCriticalSection * m_pCSection Our CS
Private data CGenericCriticalSection * m_pCSectionCounter
Private data ThreadData * * m_ppThreadData Thread data
Private data CGenericThread * * m_ppThreads Our array of threads
Private data CGenericSemaphore * m_pSemaphore Our semaphore
Private data unsigned long m_ulJobsCount Number of jobs
Private data unsigned long m_ulThreadCount Number of thread

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

Private constructor

CThreadPool( const CThreadPool& rPool )

No copy Ctor
Public constructor

CThreadPool( unsigned long ulNumberOfThreads, unsigned long ulMaxJobsPending=THREAD_POOL_DEFAULT_JOBS, LPInitializePoolProc pInitializeProc=NULL, CGenericThread::ThreadPriority aPriority=CGenericThread::tpNormal )

Ctor and Dtor ulNumberOfThreads - Number of active threads ulMaxJobsPending - Size of the back queue pInitializeProc - Initialize proc aPriority - Threads priority

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

Public destructor virtual

~CThreadPool()

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

Public function void

Clear()

Clear the data
Private function void

ClearThreads()

delete all the threads
Private function void

GetJob( JobData& aData )

Get a job
Public function DWORD

GetMaxThreads() const

Get the number of threads
Public function int

GetRunningThreads() const

Get the number of running threads
Private function CGenericSemaphore *

GetSemaphore() const

Get the semaphore
Public function int

GetWaitingJobs() const

How many jobs we have
Public function BOOL

IsFinished() const

Did we finish running
Public function BOOL

IsInitialized() const

Is the pool initialized ?
Private function CThreadPool &

operator =( const CThreadPool& rPool )

No assignment operator
Private function static DWORD

PoolThread( LPVOID pParam )

Our thread proc
Private function void

ReSetThreadCount( int iIncrement )

We have another or less thread running
Public function void

SetExtraDataDrop( BOOL bDrop )

Do we allow extra data to block, or to be dropped ?
Public function void

SetSleepInterval( DWORD dwSleepInterval )

Set the sleep interval
Private function BOOL

SpawnThreads( LPInitializePoolProc pInitializeProc, CGenericThread::ThreadPriority aPriority )

Create the threads
Private function BOOL

SubmitJob( LPThreadPoolProc pJobProc, LPThreadDWORDPoolProc pDWORDJobProc, LPThreadPoolDataProc pDataProc, LPVOID lpData )

Submit the job localy
Public function BOOL

SubmitJob( LPThreadPoolProc pJobProc, LPVOID lpData )

Add a job
Public function BOOL

SubmitJob( LPThreadDWORDPoolProc pJobProc, LPVOID lpData )

Public function BOOL

SubmitJob( LPThreadPoolDataProc pJobProc, LPVOID lpData )

'Custom Code' icon -- Shortcut to top of page. Custom Code

'Implementation Details' icon -- Shortcut to top of page. Implementation Details

File(s)
C:\dev\Komodia\ThreadPool.cpp
C:\dev\Komodia\ThreadPool.h
Header Includes
ErrorHandler.h     
GenericThread.h     
deque     
Source Includes
stdafx.h     for precompiled header directive
ThreadPool.h     
ErrorHandlerMacros.h     
GenericSemaphore.h     
GenericCriticalSection.h     
GenericEvent.h     
WaitList.h     
OSManager.h     
Owner
tcpip4
Last Modified
05/02/2003 19:58:49 PM

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.