| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- { $HDR$}
- {**********************************************************************}
- { Unit archived using Team Coherence }
- { Team Coherence is Copyright 2002 by Quality Software Components }
- { }
- { For further information / comments, visit our WEB site at }
- { http://www.TeamCoherence.com }
- {**********************************************************************}
- {}
- { $Log: 10379: IdThreadMgr.pas
- {
- { Rev 1.0 2002.11.12 10:56:08 PM czhower
- }
- unit IdThreadMgr;
- (*
- Changes
- 02 Oct 2001 - Allen O'Neill - Added support for thread priority - new property Threadpriority, new line added to OnCreate {Do not Localize}
- *)
- interface
- uses
- Classes,
- IdException, IdBaseComponent, IdGlobal, IdThread,
- SyncObjs;
- type
- TIdThreadMgr = class(TIdBaseComponent)
- protected
- FActiveThreads: TThreadList;
- FThreadClass: TIdThreadClass;
- FThreadPriority: TIdThreadPriority;
- public
- constructor Create(AOwner: TComponent); override;
- function CreateNewThread: TIdThread; virtual;
- destructor Destroy; override;
- function GetThread: TIdThread; virtual; abstract;
- procedure ReleaseThread(AThread: TIdThread); virtual; abstract;
- procedure TerminateThreads; virtual;
- //
- property ActiveThreads: TThreadList read FActiveThreads;
- property ThreadClass: TIdThreadClass read FThreadClass write FThreadClass;
- property ThreadPriority: TIdThreadPriority read FThreadPriority
- write FThreadPriority default tpNormal;
- end;
- EIdThreadMgrError = class(EIdException);
- EIdThreadClassNotSpecified = class(EIdThreadMgrError);
- implementation
- uses
- IdResourceStrings, IdTCPServer,
- SysUtils;
- { TIdThreadMgr }
- constructor TIdThreadMgr.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FActiveThreads := TThreadList.Create;
- FThreadPriority := tpNormal;
- end;
- function TIdThreadMgr.CreateNewThread: TIdThread;
- begin
- if ThreadClass = nil then begin
- raise EIdThreadClassNotSpecified.create(RSThreadClassNotSpecified);
- end;
- Result := TIdThreadClass(ThreadClass).Create;
- SetThreadPriority(Result, ThreadPriority);
- end;
- destructor TIdThreadMgr.Destroy;
- begin
- FreeAndNil(FActiveThreads);
- inherited Destroy;
- end;
- procedure TIdThreadMgr.TerminateThreads;
- begin
- //
- end;
- end.
|