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, IThreadPoolWorkerThreadFactory &threadFactory) | |
CThreadPoolEx (IMonitorThreadPool &monitor, ThreadCount initialThreads, ThreadCount minThreads, ThreadCount maxThreads, ThreadCount maxDormantThreads, Milliseconds poolMaintPeriod, long maxQueuedItems, IThreadPoolWorkerThreadFactory &threadFactory) | |
CThreadPoolEx (const CThreadPoolEx &rhs) | |
~CThreadPoolEx () override | |
Cleans up. Shuts down the pool if it has been started. | |
CThreadPoolEx & | operator= (const CThreadPoolEx &rhs) |
void | SetThreadName (const _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 _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. | |
void | WaitForShutdownToComplete () |
void | Dispatch (ULONG_PTR completionKey, DWORD numberOfBytes=0, 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... |
typedef unsigned short ThreadCount |
typedef ThreadIdentifier ThreadIdentifier |
Reimplemented from IManageThreadPoolThreads.
CThreadPoolEx | ( | ThreadCount | initialThreads, | |
ThreadCount | minThreads, | |||
ThreadCount | maxThreads, | |||
ThreadCount | maxDormantThreads, | |||
Milliseconds | poolMaintPeriod, | |||
long | maxQueuedItems, | |||
IThreadPoolWorkerThreadFactory & | threadFactory | |||
) |
CThreadPoolEx | ( | IMonitorThreadPool & | monitor, | |
ThreadCount | initialThreads, | |||
ThreadCount | minThreads, | |||
ThreadCount | maxThreads, | |||
ThreadCount | maxDormantThreads, | |||
Milliseconds | poolMaintPeriod, | |||
long | maxQueuedItems, | |||
IThreadPoolWorkerThreadFactory & | threadFactory | |||
) |
CThreadPoolEx | ( | const CThreadPoolEx & | rhs | ) |
~CThreadPoolEx | ( | ) | [override] |
Cleans up. Shuts down the pool if it has been started.
CThreadPoolEx& operator= | ( | const CThreadPoolEx & | rhs | ) |
void SetThreadName | ( | const _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 _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.
void WaitForShutdownToComplete | ( | ) |
void Dispatch | ( | ULONG_PTR | completionKey, | |
DWORD | numberOfBytes = 0 , |
|||
IAsyncWorkItem * | pWorkItem = nullptr | |||
) |
Dispatch a work item to the worker threads. The completion key can be any value except 0.
void StartWorkerThread | ( | ) |