The C++ framework for developing highly scalable, high performance servers on Windows platforms.

CThreadPoolEx Class Reference

Inheritance diagram for CThreadPoolEx:
Collaboration diagram for CThreadPoolEx:

List of all members.

Public Types

typedef unsigned short ThreadCount
typedef ThreadIdentifier ThreadIdentifier

Public Member Functions

 CThreadPoolEx (ThreadCount initialThreads, ThreadCount minThreads, ThreadCount maxThreads, ThreadCount maxDormantThreads, Milliseconds poolMaintPeriod, long maxQueuedItems, JetByteTools::Core::IThreadPoolWorkerThreadFactory &threadFactory)
 CThreadPoolEx (JetByteTools::Core::IMonitorThreadPool &monitor, ThreadCount initialThreads, ThreadCount minThreads, ThreadCount maxThreads, ThreadCount maxDormantThreads, Milliseconds poolMaintPeriod, long maxQueuedItems, JetByteTools::Core::IThreadPoolWorkerThreadFactory &threadFactory)
 CThreadPoolEx (const CThreadPoolEx &rhs)
 ~CThreadPoolEx () override
 Cleans up. Shuts down the pool if it has been started.
CThreadPoolExoperator= (const CThreadPoolEx &rhs)
void SetThreadPriority (int priority)
 Sets the priority of the thread pool worker threads to the supplied value. Note that this must be called before calling Start() for it to have an effect.
void SetThreadName (const JetByteTools::Core::_tstring &threadName) const
 Sets the name of the thread pool worker threads as displayed in the Visual Studio debugger to the supplied name. By default the constructors set the name of the threads to "ThreadPoolEx". Note that this must be called before calling Start() for it to have an effect.
void SetMaintenanceThreadName (const JetByteTools::Core::_tstring &threadName) const
 Sets the name of the thread pool's dispatch thread as displayed in the Visual Studio debugger to the supplied name. By default the constructors set the name of this thread to "ThreadPoolExDispatch". Note that this must be called before calling Start() for it to have an effect.
void Start (bool enableMaintenance=true)
 Starts the thread pool. Creates the pool maintenance thread and the specified number of initial threads for the pool. Optionally enables dormant thread maintenance.
bool EnableMaintenance (bool enableMaintenance=true, bool maintenanceEnabledForOnePassOnly=false)
 Enable or disable dormant thread maintenance.
void BeginShutdown ()
 Start the shutdown proceedure. All worker threads will be shutdown once they finish working on their current work item the pool maitenance thread will be shut down.
bool WaitForShutdownToComplete (Milliseconds forceTerminationAfter=INFINITE)
 Waits for the worker threads and pool maintenance thread to shut down. Can be set to forcibly terminate worker threads if they take longer than forceTerminationAfterMillis milliseconds to terminate on their own. It's generally best to leave this set at INFINITE and NOT forcibly terminate worker threads. Returns true if threads were forcibly terminated.
void Dispatch (ULONG_PTR completionKey, DWORD numberOfBytes=0, JetByteTools::Core::IAsyncWorkItem *pWorkItem=nullptr)
 Dispatch a work item to the worker threads. The completion key can be any value except 0.
void StartWorkerThread ()

Classes

class  WorkerThread
 A worker thread for the CThreadPoolEx. The user work is done by an instance of IThreadPoolExWorkerThread which is created by the supplied factory in the worker thread's constructor and destroyed in the destructor. More...


Member Typedef Documentation

typedef unsigned short ThreadCount


Constructor & Destructor Documentation

CThreadPoolEx ( ThreadCount  initialThreads,
ThreadCount  minThreads,
ThreadCount  maxThreads,
ThreadCount  maxDormantThreads,
Milliseconds  poolMaintPeriod,
long  maxQueuedItems,
JetByteTools::Core::IThreadPoolWorkerThreadFactory threadFactory 
)

CThreadPoolEx ( JetByteTools::Core::IMonitorThreadPool monitor,
ThreadCount  initialThreads,
ThreadCount  minThreads,
ThreadCount  maxThreads,
ThreadCount  maxDormantThreads,
Milliseconds  poolMaintPeriod,
long  maxQueuedItems,
JetByteTools::Core::IThreadPoolWorkerThreadFactory threadFactory 
)

CThreadPoolEx ( const CThreadPoolEx rhs  ) 

~CThreadPoolEx (  )  [override]

Cleans up. Shuts down the pool if it has been started.


Member Function Documentation

CThreadPoolEx& operator= ( const CThreadPoolEx rhs  ) 

void SetThreadPriority ( int  priority  ) 

Sets the priority of the thread pool worker threads to the supplied value. Note that this must be called before calling Start() for it to have an effect.

void SetThreadName ( const JetByteTools::Core::_tstring threadName  )  const

Sets the name of the thread pool worker threads as displayed in the Visual Studio debugger to the supplied name. By default the constructors set the name of the threads to "ThreadPoolEx". Note that this must be called before calling Start() for it to have an effect.

void SetMaintenanceThreadName ( const JetByteTools::Core::_tstring threadName  )  const

Sets the name of the thread pool's dispatch thread as displayed in the Visual Studio debugger to the supplied name. By default the constructors set the name of this thread to "ThreadPoolExDispatch". Note that this must be called before calling Start() for it to have an effect.

void Start ( bool  enableMaintenance = true  ) 

Starts the thread pool. Creates the pool maintenance thread and the specified number of initial threads for the pool. Optionally enables dormant thread maintenance.

bool EnableMaintenance ( bool  enableMaintenance = true,
bool  maintenanceEnabledForOnePassOnly = false 
)

Enable or disable dormant thread maintenance.

void BeginShutdown (  ) 

Start the shutdown proceedure. All worker threads will be shutdown once they finish working on their current work item the pool maitenance thread will be shut down.

bool WaitForShutdownToComplete ( Milliseconds  forceTerminationAfter = INFINITE  ) 

Waits for the worker threads and pool maintenance thread to shut down. Can be set to forcibly terminate worker threads if they take longer than forceTerminationAfterMillis milliseconds to terminate on their own. It's generally best to leave this set at INFINITE and NOT forcibly terminate worker threads. Returns true if threads were forcibly terminated.

void Dispatch ( ULONG_PTR  completionKey,
DWORD  numberOfBytes = 0,
JetByteTools::Core::IAsyncWorkItem pWorkItem = nullptr 
)

Dispatch a work item to the worker threads. The completion key can be any value except 0.

void StartWorkerThread (  ) 


Generated on Sun Sep 12 19:11:52 2021 for The Server Framework - v7.4 by doxygen 1.5.3