Parcourir la source

* closethread thread manager field/function. Mantis 13160

git-svn-id: trunk@15072 -
marco il y a 15 ans
Parent
commit
8cce3d3f91
5 fichiers modifiés avec 34 ajouts et 0 suppressions
  1. 14 0
      rtl/inc/thread.inc
  2. 2 0
      rtl/inc/threadh.inc
  3. 6 0
      rtl/os2/systhrd.inc
  4. 5 0
      rtl/unix/cthreads.pp
  5. 7 0
      rtl/win/systhrd.inc

+ 14 - 0
rtl/inc/thread.inc

@@ -143,6 +143,12 @@ begin
   Result:=CurrentTM.ResumeThread(ThreadHandle);
 end;
 
+function CloseThread  (threadHandle : TThreadID):dword;
+
+begin
+  result:=CurrentTM.CloseThread(ThreadHandle);
+end;
+
 procedure ThreadSwitch;
 
 begin
@@ -359,6 +365,13 @@ begin
   NoThreadError;
 end;
 
+function NoCloseThread  (threadHandle : TThreadID):dword;
+
+begin
+ Result:=0;      // avoid warnings.
+ NoThreadError;
+end;
+
 function  NoWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;  {0=no timeout}
 begin
   NoThreadError;
@@ -585,6 +598,7 @@ begin
     SuspendThread          :=@NoThreadHandler;
     ResumeThread           :=@NoThreadHandler;
     KillThread             :=@NoThreadHandler;
+    CloseThread		   :=@NoCloseThread;
     ThreadSwitch           :=@NoThreadSwitch;
     WaitForThreadTerminate :=@NoWaitForThreadTerminate;
     ThreadSetPriority      :=@NoThreadSetPriority;

+ 2 - 0
rtl/inc/threadh.inc

@@ -62,6 +62,7 @@ type
     SuspendThread          : TThreadHandler;
     ResumeThread           : TThreadHandler;
     KillThread             : TThreadHandler;
+    CloseThread            : TThreadHandler;
     ThreadSwitch           : TThreadSwitchHandler;
     WaitForThreadTerminate : TWaitForThreadTerminateHandler;
     ThreadSetPriority      : TThreadSetPriorityHandler;
@@ -133,6 +134,7 @@ procedure EndThread;
 procedure FlushThread;
 function  SuspendThread (threadHandle : TThreadID) : dword;
 function  ResumeThread  (threadHandle : TThreadID) : dword;
+function  CloseThread   (threadHandle : TThreadID) : dword;
 procedure ThreadSwitch;                                                                {give time to other threads}
 function  KillThread (threadHandle : TThreadID) : dword;
 function  WaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;  {0=no timeout}

+ 6 - 0
rtl/os2/systhrd.inc

@@ -253,6 +253,11 @@ end;
 }
     end;
 
+    function SysCloseThread (threadHandle : TThreadID) : dword;
+    begin
+//      SysCloseThread:=CloseHandle(threadHandle);
+    end;
+
     function SysWaitForThreadTerminate (ThreadHandle: dword;
                                                     TimeoutMs: longint): dword;
     begin
@@ -450,6 +455,7 @@ begin
     WaitForThreadTerminate :=@SysWaitForThreadTerminate;
     ThreadSetPriority      :=@SysThreadSetPriority;
     ThreadGetPriority      :=@SysThreadGetPriority;
+    CloseThrad		   :=@SysCloseThread;
     GetCurrentThreadId     :=@SysGetCurrentThreadId;
     InitCriticalSection    :=@SysInitCriticalSection;
     DoneCriticalSection    :=@SysDoneCriticalSection;

+ 5 - 0
rtl/unix/cthreads.pp

@@ -369,6 +369,10 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
       CKillThread := pthread_cancel(pthread_t(threadHandle));
     end;
 
+  function CCloseThread (threadHandle : TThreadID) : dword;
+    begin
+      result:=0;
+    end;
 
   function  CWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;  {0=no timeout}
     var
@@ -944,6 +948,7 @@ begin
     ResumeThread           :=@CResumeThread;
     KillThread             :=@CKillThread;
     ThreadSwitch           :=@CThreadSwitch;
+    CloseThread	           :=@CCloseThread;
     WaitForThreadTerminate :=@CWaitForThreadTerminate;
     ThreadSetPriority      :=@CThreadSetPriority;
     ThreadGetPriority      :=@CThreadGetPriority;

+ 7 - 0
rtl/win/systhrd.inc

@@ -46,6 +46,7 @@ function LocalFree(hMem : Pointer):Pointer; {$ifdef wince}cdecl{$else}stdcall{$e
 procedure Sleep(dwMilliseconds: DWord); {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'Sleep';
 function  WinSuspendThread (threadHandle : THandle) : dword; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'SuspendThread';
 function  WinResumeThread  (threadHandle : THandle) : dword; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'ResumeThread';
+function  WinCloseHandle  (threadHandle : THandle) : dword; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'CloseHandle';
 function  TerminateThread  (threadHandle : THandle; var exitCode : dword) : boolean; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'TerminateThread';
 function  WaitForSingleObject (hHandle : THandle;Milliseconds: dword): dword; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'WaitForSingleObject';
 function  WinThreadSetPriority (threadHandle : THandle; Prio: longint): boolean; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'SetThreadPriority';
@@ -302,6 +303,11 @@ CONST
         SysKillThread := 0;
     end;
 
+    function  SysCloseThread (threadHandle : TThreadID) : dword;
+    begin
+      SysCloseThread:=winCloseHandle(threadHandle);
+    end;
+
     function  SysWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;
     begin
       if timeoutMs = 0 then dec (timeoutMs);  // $ffffffff is INFINITE
@@ -461,6 +467,7 @@ begin
     ResumeThread           :=@SysResumeThread;
     KillThread             :=@SysKillThread;
     ThreadSwitch           :=@SysThreadSwitch;
+    CloseThread		   :=@SysCloseThread;
     WaitForThreadTerminate :=@SysWaitForThreadTerminate;
     ThreadSetPriority      :=@SysThreadSetPriority;
     ThreadGetPriority      :=@SysThreadGetPriority;