{$MODE OBJFPC}
{$MODESWITCH AUTODEREF}
unit dthread;

interface

type
  TThreadId = system.TThreadId;
  TThreadFunc = function (Parameter: Pointer): PtrInt;

function BeginThread(ThreadFunction: TThreadFunc; Parameter: Pointer = nil): TThreadId; inline;
// TimeoutMs=0 for no timeout
function WaitForThreadTerminate(Thread: TThreadId; TimeoutMs: LongInt = 0): LongInt; inline;
function KillThread(Thread: TThreadId): LongInt; inline;

implementation

function BeginThread(ThreadFunction: TThreadFunc; Parameter: Pointer): TThreadId;
begin
  Result := System.BeginThread(ThreadFunction, Parameter);
end;

function WaitForThreadTerminate(Thread: TThreadId; TimeoutMs: LongInt): LongInt;
begin
  Result := System.WaitForThreadTerminate(Thread, TimeoutMs);
end;

function KillThread(Thread: TThreadId): LongInt;
begin
  Result := System.KillThread(Thread);
end;

end.
