Internet Direct (Indy) Version 9.0.2 Beta
TIdThreadMgrPool
Provides thread management using a pool of TIdThread instances.

TIdThreadMgrPool = class(TIdThreadMgr)
Description
TIdThreadMgrPool is a thread manager that utilizes the thread management framework defined in TIdThreadMgr. TIdThreadMgrPool provides thread management using a pool of TIdThread instances. Threads are created by the thread manager, when necessary, or retrieved from the thread pool. TIdThreadMgrPool also keeps a list of active threads.

The thread pool can have a maximum size to conserve system resources.

TIdThreadMgrPool uses Lock to protect thread manager resources in GetThread and ReleaseThread.

TIdThreadMgrPool implements the inherited abstract methods GetThread and ReleaseThread. GetThread provides a thread instance for the thread manager. ReleaseThread handles freeing and releasing a thread instance, or returning the instance to the thread pool.

Use TerminateThreads to notify all TIdThread instances to close their socket connection, release the thread, and remove the thread from ActiveThreads.

Assign an instance of TIdThreadClass to ThreadClass before using the thread manager to allocate new threads.

To use TIdThreadMgrPool with TIdTCPServer, create an instance of TIdThreadMgrPool, and assign the object reference to TIdTCPServer.ThreadMgr. If you are using protocols which do not close the socket connection after each request, you may wish to consider using the TIdThreadMgrDefault thread manager. After closing a connection with TIdThreadMgrDefault, the thread and all associated data is freed. When you are using TIdThreadMgrPool, the threads is stored in the Pool and when the server needs new thread it is not created but is taken from the Pool.