mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 16:31:36 +01:00 
			
		
		
		
	* fixed leaking of TThread
git-svn-id: trunk@3519 -
This commit is contained in:
		
							parent
							
								
									6f1e0eff45
								
							
						
					
					
						commit
						33baacbe04
					
				| @ -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 } | ||||
|  | ||||
| @ -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 } | ||||
|  | ||||
| @ -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 } | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 } | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 } | ||||
|  | ||||
| @ -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 } | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 } | ||||
|  | ||||
| @ -112,7 +112,6 @@ CONST | ||||
|       end; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| {***************************************************************************** | ||||
|                             Thread starting | ||||
| *****************************************************************************} | ||||
|  | ||||
| @ -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; | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 florian
						florian