* Correctly set current thread

This commit is contained in:
Michaël Van Canneyt 2025-04-03 16:26:27 +02:00
parent 3bf5c67485
commit 1a21ea41b8

View File

@ -399,12 +399,14 @@ procedure WasiAllocateThreadVars; forward;
{$push}{$S-} // no stack checking for this procedure
procedure FPCWasmThreadStartPascal(tid: longint; start_arg: PWasmThread);
begin
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('FPCWasmThreadStartPascal(...)');{$ENDIF}
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('FPCWasmThreadStartPascal('+IntToStr(tid)+','+IntToStr(ptrint(start_arg))+')');{$ENDIF}
start_arg^.ID:=tid;
GlobalCurrentThread:=@start_arg;
GlobalCurrentThread:=start_arg;
GlobalIsMainThread:=0;
GlobalIsWorkerThread:=1;
{$IFDEF DEBUGWASMTHREADS}DebugWriteln('Check : TID='+IntToStr(tid)+', start_arg_id='+IntToStr(start_arg^.ID)+', currentthread= '+IntTostr(ptrint(GetCurrentThreadID))+')');{$ENDIF}
{$IFDEF FPC_WASM_WORKER_THREADS_CAN_WAIT}
GlobalIsThreadBlockable:=1;
{$ELSE FPC_WASM_WORKER_THREADS_CAN_WAIT}
@ -610,6 +612,7 @@ begin
Result:=0;
end;
function WasiGetCurrentThreadId : TThreadID;
begin
Result:=GetSelfThread;