Indy 9
TIdThreadMgrDefault
Hierarchy, Properties, Methods, See Also, Unit: IdThreadMgrDefault
Default thread manager for Indy servers.
TIdThreadMgrDefault = class(TIdThreadMgr)
Unit
IdThreadMgrDefault
Description
TIdThreadMgrDefault is a descendant of TIDThreadMgr that acts as the default thread manager in Indy for TIdTCPServer and descendants. TIdThreadMgrDefault utilizes the thread management framework defined in TIdThreadMgr. TIdThreadMgrDefault creates and destroys threads for every connection, and stores active thread instances in the ActiveThreads list.

TIdThreadMgrDefault implements the inherited abstract methods GetThread and ReleaseThread. GetThread creates a new thread instance for the thread manager. ReleaseThread handles freeing and releasing a thread instance.

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.

TIdThreadMgrDefault is the default thread manager created for instances of TIdTCPServer and descendants. To use another thread manager, create an instance of a TIdThreadMgr descendant, and assign the object reference to TIdTCPServer.ThreadMgr. If you are using protocols such as HTTP, Time, or Gopher, where the connection is closed after the request is fulfilled, you may wish to consider using the TIdThreadMgrPool 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.


TIdThreadMgrDefault.GetThread
TIdThreadMgrDefault, See Also
Requests a new thread for the thread manager.
function GetThread: TIdThread; override;
Return Value
TIdThread - The new thread instance.
Description
TIdThreadMgrDefault implements GetThread to provide new thread instances for the thread manager. GetThread uses CreateNewThread to obtain the new thread instance. GetThread also adds the new thread instance to ActiveThreads.

A thread instance can be freed using ReleaseThread.

A list of threads can be terminated and freed using TerminateThreads.


TIdThreadMgrDefault.ReleaseThread
TIdThreadMgrDefault, See Also
Frees a thread instance.
procedure ReleaseThread(AThread: TIdThread); override;
Parameters
AThread: TIdThread
Thread to be released.
Description
ReleaseThread is an implementation of the inherited abstract method that instructs the thread manager to terminate and free a thread instance.

If AThread is the current thread of execution, and has not been Suspended, the thread calls TerminateAndWaitFor to force termination of the active thread. TIdThread.Free is called to release the thread. If AThread is not the current thread, FreeOnTerminate is set to True.

ReleaseThread removes the thread from ActiveThreads prior to exiting from the method.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.