Indy 9
|
TIdThreadMgrDefault = class(TIdThreadMgr)
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.
function GetThread: TIdThread; override;
A thread instance can be freed using ReleaseThread.
A list of threads can be terminated and freed using TerminateThreads.
procedure ReleaseThread(AThread: TIdThread); override;
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.