made HTMLLite single threaded

git-svn-id: trunk@3770 -
This commit is contained in:
mattias 2002-12-31 11:07:07 +00:00
parent 6d738f185e
commit d4187e89b6
4 changed files with 131 additions and 4 deletions

View File

@ -2504,6 +2504,14 @@ begin
,da_DefineRecurse));
MainDir.AddChild(DirTempl);
// components/htmllite
SubDirTempl:=TDefineTemplate.Create('HTMLLite',
'HTMLLite',
'','htmllite',da_Directory);
SubDirTempl.AddChild(TDefineTemplate.Create('HL_LAZARUS',
'Define HL_LAZARUS','HL_LAZARUS','',da_DefineRecurse));
DirTempl.AddChild(SubDirTempl);
// components/custom
SubDirTempl:=TDefineTemplate.Create('Custom Components',
ctsCustomComponentsDirectory,

View File

@ -7,6 +7,7 @@
{$Define ver100_plus}
{$Define ver120_plus}
{$Define NoGIF}
{$Define NoThreads}
{$ELSE}

View File

@ -167,7 +167,7 @@ type
Base: string;
BaseTarget: string;
AllowSuspend: boolean;
ParseThread: TThread;
ParseThread: {$IFDEF NoThreads}TObject{$ELSE}TThread{$ENDIF};
CurrentStyle: TFontStyles; {as set by <b>, <i>, etc.}
CurrentSScript: SubSuperType;
CurrentForm: ThtmlForm;

View File

@ -15,7 +15,46 @@ uses
Classes, LitePars;
type
TParseThread = class(TThread)
TFakeThread = class
private
FHandle: THandle;
FThreadID: THandle;
FTerminated: Boolean;
FSuspended: Boolean;
FFreeOnTerminate: Boolean;
FFinished: Boolean;
FReturnValue: Integer;
FOnTerminate: TNotifyEvent;
FPriority: TThreadPriority;
FMethod: TThreadMethod;
FSynchronizeException: TObject;
procedure CallOnTerminate;
function GetPriority: TThreadPriority;
procedure SetPriority(Value: TThreadPriority);
procedure SetSuspended(Value: Boolean);
procedure DoExecute;
protected
procedure DoTerminate; virtual;
procedure Execute; virtual; abstract;
procedure Synchronize(Method: TThreadMethod);
property ReturnValue: Integer read FReturnValue write FReturnValue;
property Terminated: Boolean read FTerminated;
public
constructor Create(CreateSuspended: Boolean);
destructor Destroy; override;
procedure Resume;
procedure Suspend;
procedure Terminate;
function WaitFor: Integer;
property FreeOnTerminate: Boolean read FFreeOnTerminate write FFreeOnTerminate;
property Handle: THandle read FHandle;
property Priority: TThreadPriority read GetPriority write SetPriority;
property Suspended: Boolean read FSuspended write SetSuspended;
property ThreadID: THandle read FThreadID;
property OnTerminate: TNotifyEvent read FOnTerminate write FOnTerminate;
end;
TParseThread = class({$IFDEF NoThreads}TFakeThread{$ELSE}TThread{$ENDIF})
private
{ Private declarations }
protected
@ -35,7 +74,7 @@ type
constructor Create(CreateSuspended: Boolean);
destructor Destroy; override;
procedure Synchronize(Method: TThreadMethod);
procedure AddString(S: string);
procedure AddString({$IFDEF HL_LAZARUS}const {$ENDIF}S: string);
end;
@ -51,7 +90,7 @@ Buffer := PChar(St);
BuffEnd := Buffer;
end;
procedure TParseThread.AddString(S: string);
procedure TParseThread.AddString({$IFDEF HL_LAZARUS}const {$ENDIF}S: string);
{Call only when thread is suspended}
var
Space: integer;
@ -82,5 +121,84 @@ begin
inherited;
end;
{ TFakeThread }
procedure TFakeThread.CallOnTerminate;
begin
end;
function TFakeThread.GetPriority: TThreadPriority;
begin
Result:=FPriority;
end;
procedure TFakeThread.SetPriority(Value: TThreadPriority);
begin
FPriority:=Value;
end;
procedure TFakeThread.SetSuspended(Value: Boolean);
begin
FSuspended:=Value;
end;
procedure TFakeThread.DoExecute;
begin
FSuspended:=false;
Execute;
FSuspended:=true;
DoTerminate;
end;
procedure TFakeThread.DoTerminate;
begin
if Assigned(FOnTerminate) then
FOnTerminate(Self);
FFinished:=true;
if FFreeOnTerminate then Free;
end;
procedure TFakeThread.Synchronize(Method: TThreadMethod);
begin
end;
constructor TFakeThread.Create(CreateSuspended: Boolean);
begin
inherited Create;
if CreateSuspended then Suspend else DoExecute;
end;
destructor TFakeThread.Destroy;
begin
if not FFinished and not Suspended then
begin
Terminate;
WaitFor;
end;
inherited Destroy;
end;
procedure TFakeThread.Resume;
begin
if not FFinished then DoExecute;
end;
procedure TFakeThread.Suspend;
begin
FSuspended := true;
end;
procedure TFakeThread.Terminate;
begin
FTerminated := True;
end;
function TFakeThread.WaitFor: Integer;
begin
Result:=0;
end;
end.