mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 11:29:16 +02:00
* closethread thread manager field/function. Mantis 13160
git-svn-id: trunk@15072 -
This commit is contained in:
parent
d8a902b4c4
commit
8cce3d3f91
@ -143,6 +143,12 @@ begin
|
|||||||
Result:=CurrentTM.ResumeThread(ThreadHandle);
|
Result:=CurrentTM.ResumeThread(ThreadHandle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CloseThread (threadHandle : TThreadID):dword;
|
||||||
|
|
||||||
|
begin
|
||||||
|
result:=CurrentTM.CloseThread(ThreadHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure ThreadSwitch;
|
procedure ThreadSwitch;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -359,6 +365,13 @@ begin
|
|||||||
NoThreadError;
|
NoThreadError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function NoCloseThread (threadHandle : TThreadID):dword;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=0; // avoid warnings.
|
||||||
|
NoThreadError;
|
||||||
|
end;
|
||||||
|
|
||||||
function NoWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
|
function NoWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
|
||||||
begin
|
begin
|
||||||
NoThreadError;
|
NoThreadError;
|
||||||
@ -585,6 +598,7 @@ begin
|
|||||||
SuspendThread :=@NoThreadHandler;
|
SuspendThread :=@NoThreadHandler;
|
||||||
ResumeThread :=@NoThreadHandler;
|
ResumeThread :=@NoThreadHandler;
|
||||||
KillThread :=@NoThreadHandler;
|
KillThread :=@NoThreadHandler;
|
||||||
|
CloseThread :=@NoCloseThread;
|
||||||
ThreadSwitch :=@NoThreadSwitch;
|
ThreadSwitch :=@NoThreadSwitch;
|
||||||
WaitForThreadTerminate :=@NoWaitForThreadTerminate;
|
WaitForThreadTerminate :=@NoWaitForThreadTerminate;
|
||||||
ThreadSetPriority :=@NoThreadSetPriority;
|
ThreadSetPriority :=@NoThreadSetPriority;
|
||||||
|
@ -62,6 +62,7 @@ type
|
|||||||
SuspendThread : TThreadHandler;
|
SuspendThread : TThreadHandler;
|
||||||
ResumeThread : TThreadHandler;
|
ResumeThread : TThreadHandler;
|
||||||
KillThread : TThreadHandler;
|
KillThread : TThreadHandler;
|
||||||
|
CloseThread : TThreadHandler;
|
||||||
ThreadSwitch : TThreadSwitchHandler;
|
ThreadSwitch : TThreadSwitchHandler;
|
||||||
WaitForThreadTerminate : TWaitForThreadTerminateHandler;
|
WaitForThreadTerminate : TWaitForThreadTerminateHandler;
|
||||||
ThreadSetPriority : TThreadSetPriorityHandler;
|
ThreadSetPriority : TThreadSetPriorityHandler;
|
||||||
@ -133,6 +134,7 @@ procedure EndThread;
|
|||||||
procedure FlushThread;
|
procedure FlushThread;
|
||||||
function SuspendThread (threadHandle : TThreadID) : dword;
|
function SuspendThread (threadHandle : TThreadID) : dword;
|
||||||
function ResumeThread (threadHandle : TThreadID) : dword;
|
function ResumeThread (threadHandle : TThreadID) : dword;
|
||||||
|
function CloseThread (threadHandle : TThreadID) : dword;
|
||||||
procedure ThreadSwitch; {give time to other threads}
|
procedure ThreadSwitch; {give time to other threads}
|
||||||
function KillThread (threadHandle : TThreadID) : dword;
|
function KillThread (threadHandle : TThreadID) : dword;
|
||||||
function WaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
|
function WaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
|
||||||
|
@ -253,6 +253,11 @@ end;
|
|||||||
}
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SysCloseThread (threadHandle : TThreadID) : dword;
|
||||||
|
begin
|
||||||
|
// SysCloseThread:=CloseHandle(threadHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
function SysWaitForThreadTerminate (ThreadHandle: dword;
|
function SysWaitForThreadTerminate (ThreadHandle: dword;
|
||||||
TimeoutMs: longint): dword;
|
TimeoutMs: longint): dword;
|
||||||
begin
|
begin
|
||||||
@ -450,6 +455,7 @@ begin
|
|||||||
WaitForThreadTerminate :=@SysWaitForThreadTerminate;
|
WaitForThreadTerminate :=@SysWaitForThreadTerminate;
|
||||||
ThreadSetPriority :=@SysThreadSetPriority;
|
ThreadSetPriority :=@SysThreadSetPriority;
|
||||||
ThreadGetPriority :=@SysThreadGetPriority;
|
ThreadGetPriority :=@SysThreadGetPriority;
|
||||||
|
CloseThrad :=@SysCloseThread;
|
||||||
GetCurrentThreadId :=@SysGetCurrentThreadId;
|
GetCurrentThreadId :=@SysGetCurrentThreadId;
|
||||||
InitCriticalSection :=@SysInitCriticalSection;
|
InitCriticalSection :=@SysInitCriticalSection;
|
||||||
DoneCriticalSection :=@SysDoneCriticalSection;
|
DoneCriticalSection :=@SysDoneCriticalSection;
|
||||||
|
@ -369,6 +369,10 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
|||||||
CKillThread := pthread_cancel(pthread_t(threadHandle));
|
CKillThread := pthread_cancel(pthread_t(threadHandle));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CCloseThread (threadHandle : TThreadID) : dword;
|
||||||
|
begin
|
||||||
|
result:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
function CWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
|
function CWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword; {0=no timeout}
|
||||||
var
|
var
|
||||||
@ -944,6 +948,7 @@ begin
|
|||||||
ResumeThread :=@CResumeThread;
|
ResumeThread :=@CResumeThread;
|
||||||
KillThread :=@CKillThread;
|
KillThread :=@CKillThread;
|
||||||
ThreadSwitch :=@CThreadSwitch;
|
ThreadSwitch :=@CThreadSwitch;
|
||||||
|
CloseThread :=@CCloseThread;
|
||||||
WaitForThreadTerminate :=@CWaitForThreadTerminate;
|
WaitForThreadTerminate :=@CWaitForThreadTerminate;
|
||||||
ThreadSetPriority :=@CThreadSetPriority;
|
ThreadSetPriority :=@CThreadSetPriority;
|
||||||
ThreadGetPriority :=@CThreadGetPriority;
|
ThreadGetPriority :=@CThreadGetPriority;
|
||||||
|
@ -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';
|
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 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 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 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 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';
|
function WinThreadSetPriority (threadHandle : THandle; Prio: longint): boolean; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'SetThreadPriority';
|
||||||
@ -302,6 +303,11 @@ CONST
|
|||||||
SysKillThread := 0;
|
SysKillThread := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SysCloseThread (threadHandle : TThreadID) : dword;
|
||||||
|
begin
|
||||||
|
SysCloseThread:=winCloseHandle(threadHandle);
|
||||||
|
end;
|
||||||
|
|
||||||
function SysWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;
|
function SysWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;
|
||||||
begin
|
begin
|
||||||
if timeoutMs = 0 then dec (timeoutMs); // $ffffffff is INFINITE
|
if timeoutMs = 0 then dec (timeoutMs); // $ffffffff is INFINITE
|
||||||
@ -461,6 +467,7 @@ begin
|
|||||||
ResumeThread :=@SysResumeThread;
|
ResumeThread :=@SysResumeThread;
|
||||||
KillThread :=@SysKillThread;
|
KillThread :=@SysKillThread;
|
||||||
ThreadSwitch :=@SysThreadSwitch;
|
ThreadSwitch :=@SysThreadSwitch;
|
||||||
|
CloseThread :=@SysCloseThread;
|
||||||
WaitForThreadTerminate :=@SysWaitForThreadTerminate;
|
WaitForThreadTerminate :=@SysWaitForThreadTerminate;
|
||||||
ThreadSetPriority :=@SysThreadSetPriority;
|
ThreadSetPriority :=@SysThreadSetPriority;
|
||||||
ThreadGetPriority :=@SysThreadGetPriority;
|
ThreadGetPriority :=@SysThreadGetPriority;
|
||||||
|
Loading…
Reference in New Issue
Block a user