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

IMonitorThreadPool Class Reference
[InterfacesProtected destructors on abstract base classesMonitoring]

Inheritance diagram for IMonitorThreadPool:

List of all members.


Detailed Description

An interface to allow a class to monitor an instance of a thread pool. The interface assumes that threads in the pool go through the following life-cycle: created, begin processing, end processing, destroyed, and that they may optionally (hopefully not) generate errors. Obviously a thread is likely to begin and end processing several work items before it is destroyed. The methods on this interface can be called either from any thread and may not be called from the thread pool thread itself. Incrementing a counter when OnThreadCreated() is called and decrementing it when OnThreadDestroyed() is called will give you a count of the number of threads that are in existence at any one time. A corresponding counter that is incremented in OnThreadBeginProcessing() and decremented in OnThreadEndProcessing() is called will give a count of the threads that are currently in use.

Public Member Functions

virtual void OnThreadPoolThreadCreated ()=0
 Called when a thread is created. Note that this is NOT called from the thread itself.
virtual void OnThreadPoolThreadStarted ()=0
 Called when a thread is started. Note that this IS called from the thread itself.
virtual void OnThreadPoolDispatch ()=0
 Called when a work item is dispatched to the thread pool. Note that this is NOT called when I/O completions are dispatched to the pool as there's no way to know when this happens. However this IS called when you manually dispatch work items to the pool and so the difference between an events/sec counter incremented by this function and a similar counter that is incremented when processing starts will show the I/O completions.
virtual void OnThreadPoolWorkItemsDequeued (DWORD numWorkItems)=0
 Called when work items are dequeued by a thread. This includes items that are manually dispatched and I/O completions. Some pools may be able to dequeue multiple work items at once, whilst others can only dequeue a single work item at a time.
virtual void OnThreadPoolProcessingStarted (bool dataAvailable)=0
 Called when a thread in the pool starts working on a work item that has been dispatched to the pool. Some pools can be configured to issue a callback on this method when the queue reports as empty. If they do this then dataAvailable will be false.
virtual void OnThreadPoolProcessingStopped (bool dataAvailable)=0
 Called when a thread in the pool finishes working on a work item that has been dispatched to the pool. If the pool can report queue empty then this will be called with dataAvailable as false.
virtual void OnThreadPoolThreadStopped ()=0
 Called when a thread is destroyed. Note that this IS called from the thread itself.
virtual void OnThreadPoolThreadDestroyed ()=0
 Called when a thread is destroyed. Note that this is NOT called from the thread itself.
virtual void OnThreadPoolError (const _tstring &message)=0
 Called if there's an unexpected error on a thread in the pool, generally this means that there was an exception thrown whilst dealing with a work item. The thread will continue and pretty much all you can do is log or ignore the message...

Protected Member Functions

virtual ~IMonitorThreadPool ()
 We never delete instances of this interface; you must manage the lifetime of the class that implements it.

Constructor & Destructor Documentation

virtual ~IMonitorThreadPool (  )  [protected, virtual]

We never delete instances of this interface; you must manage the lifetime of the class that implements it.


Member Function Documentation

virtual void OnThreadPoolThreadCreated (  )  [pure virtual]

Called when a thread is created. Note that this is NOT called from the thread itself.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolThreadStarted (  )  [pure virtual]

Called when a thread is started. Note that this IS called from the thread itself.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolDispatch (  )  [pure virtual]

Called when a work item is dispatched to the thread pool. Note that this is NOT called when I/O completions are dispatched to the pool as there's no way to know when this happens. However this IS called when you manually dispatch work items to the pool and so the difference between an events/sec counter incremented by this function and a similar counter that is incremented when processing starts will show the I/O completions.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolWorkItemsDequeued ( DWORD  numWorkItems  )  [pure virtual]

Called when work items are dequeued by a thread. This includes items that are manually dispatched and I/O completions. Some pools may be able to dequeue multiple work items at once, whilst others can only dequeue a single work item at a time.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolProcessingStarted ( bool  dataAvailable  )  [pure virtual]

Called when a thread in the pool starts working on a work item that has been dispatched to the pool. Some pools can be configured to issue a callback on this method when the queue reports as empty. If they do this then dataAvailable will be false.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolProcessingStopped ( bool  dataAvailable  )  [pure virtual]

Called when a thread in the pool finishes working on a work item that has been dispatched to the pool. If the pool can report queue empty then this will be called with dataAvailable as false.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolThreadStopped (  )  [pure virtual]

Called when a thread is destroyed. Note that this IS called from the thread itself.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolThreadDestroyed (  )  [pure virtual]

Called when a thread is destroyed. Note that this is NOT called from the thread itself.

Implemented in CNullThreadPoolMonitor.

virtual void OnThreadPoolError ( const _tstring message  )  [pure virtual]

Called if there's an unexpected error on a thread in the pool, generally this means that there was an exception thrown whilst dealing with a work item. The thread will continue and pretty much all you can do is log or ignore the message...

Implemented in CNullThreadPoolMonitor.


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