* fixed leaking of TThread

git-svn-id: trunk@3519 -
This commit is contained in:
florian 2006-05-14 09:15:09 +00:00
parent 6f1e0eff45
commit 33baacbe04
13 changed files with 18 additions and 109 deletions

View File

@ -176,7 +176,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed');
end;
WRITE_DEBUG('thread func exiting');
WRITE_DEBUG('thread func calling EndThread');
EndThread(Result);
end;
{ TThread }

View File

@ -181,7 +181,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed');
end;
WRITE_DEBUG('thread func exiting');
WRITE_DEBUG('thread func calling EndThread');
EndThread(Result);
end;
{ TThread }

View File

@ -181,7 +181,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed');
end;
WRITE_DEBUG('thread func exiting');
WRITE_DEBUG('thread func calling EndThread');
EndThread(Result);
end;
{ TThread }

View File

@ -91,26 +91,6 @@ begin
end;
function ThreadProc(Args: pointer): Integer; cdecl;
var
FreeThread: Boolean;
Thread: TThread absolute Args;
begin
try
Thread.Execute;
except
Thread.FFatalException := TObject(AcquireExceptionObject);
end;
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then Thread.Free;
{
DosExit (deThread, Result);
}
end;
constructor TThread.Create(CreateSuspended: Boolean;
const StackSize: SizeUInt = DefaultStackSize);
var

View File

@ -172,7 +172,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed');
end;
WRITE_DEBUG('thread func exiting');
WRITE_DEBUG('thread func calling EndThread');
EndThread(Result);
end;
{ TThread }

View File

@ -125,30 +125,6 @@ begin
end;
{ TThread }
function ThreadProc(args:pointer): Integer;
var
FreeThread: Boolean;
Thread : TThread absolute args;
begin
try
Thread.Execute;
except
Thread.FFatalException := TObject(AcquireExceptionObject);
end;
FreeThread := Thread.FFreeOnTerminate;
ThreadProc := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then
begin
Thread.Destroy;
Thread.Free;
end;
EndThread(Result);
end;
constructor TThread.Create(CreateSuspended: Boolean;
const StackSize: SizeUInt = DefaultStackSize);
var

View File

@ -247,7 +247,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed'#13#10);
end;
WRITE_DEBUG('thread func exiting'#13#10);
WRITE_DEBUG('thread func calling EndThread'#13#10);
EndThread(Result);
end;
{ TThread }

View File

@ -182,7 +182,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed');
end;
WRITE_DEBUG('thread func exiting');
WRITE_DEBUG('thread func calling EndThread');
EndThread(Result);
end;
{ TThread }

View File

@ -155,24 +155,6 @@ begin
end;
function ThreadProc(Args: pointer): Integer; cdecl;
var
FreeThread: Boolean;
Thread: TThread absolute Args;
begin
try
Thread.Execute;
except
Thread.FFatalException := TObject(AcquireExceptionObject);
end;
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then Thread.Free;
DosExit (deThread, Result);
end;
constructor TThread.Create(CreateSuspended: Boolean;
const StackSize: SizeUInt = DefaultStackSize);
var

View File

@ -176,7 +176,8 @@ begin
LThread.Free;
WRITE_DEBUG('Thread freed');
end;
WRITE_DEBUG('thread func exiting');
WRITE_DEBUG('thread func calling EndThread');
EndThread(Result);
end;
{ TThread }

View File

@ -112,7 +112,6 @@ CONST
end;
{*****************************************************************************
Thread starting
*****************************************************************************}

View File

@ -85,34 +85,15 @@ procedure AddThread;
begin
if ThreadCount = 0 then
ThreadWindow := AllocateWindow;
Inc(ThreadCount);
InterlockedIncrement(ThreadCount);
end;
procedure RemoveThread;
begin
Dec(ThreadCount);
if ThreadCount = 0 then
if InterlockedDecrement(ThreadCount)=0 then
PostMessage(ThreadWindow, CM_DESTROYWINDOW, 0, 0);
end;
{ TThread }
function ThreadProc(ThreadObjPtr: Pointer): PtrInt;
var
FreeThread: Boolean;
Thread: TThread absolute ThreadObjPtr;
begin
try
Thread.Execute;
except
Thread.FFatalException := TObject(AcquireExceptionObject);
end;
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then Thread.Free;
end;
constructor TThread.Create(CreateSuspended: Boolean;
const StackSize: SizeUInt = DefaultStackSize);
@ -182,7 +163,8 @@ procedure TThread.SetSuspended(Value: Boolean);
begin
if Value <> FSuspended then
if Value then
Suspend else
Suspend
else
Resume;
end;

View File

@ -97,23 +97,6 @@ end;
{ TThread }
function ThreadProc(ThreadObjPtr: Pointer): Integer;
var
FreeThread: Boolean;
Thread: TThread absolute ThreadObjPtr;
begin
try
Thread.Execute;
except
Thread.FFatalException := TObject(AcquireExceptionObject);
end;
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then Thread.Free;
end;
constructor TThread.Create(CreateSuspended: Boolean; const StackSize: SizeUInt = DefaultStackSize);
var
Flags: Integer;