Просмотр исходного кода

* WebAssembly threads: in TThread.WaitFor, call CheckSynchronize in a loop,
while waiting on a thread that isn't finished, but the waiting happens on the
main thread. This fixes the hang in test tb0636.pp

Nikolay Nikolov 1 год назад
Родитель
Сommit
0314ba9bfd
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      rtl/wasi/tthread.inc

+ 8 - 0
rtl/wasi/tthread.inc

@@ -216,6 +216,14 @@ end;
 function TThread.WaitFor: Integer;
 
 begin
+  If (MainThreadID=GetCurrentThreadID) then
+    {
+     FFinished is set after DoTerminate, which does a synchronize of OnTerminate,
+     so make sure synchronize works (or indeed any other synchronize that may be
+     in progress)
+    }
+    While not FFinished do
+      CheckSynchronize(100);
   WaitFor:=WaitForThreadTerminate(FThreadID,-1);
   { should actually check for errors in WaitForThreadTerminate, but no }
   { error api is defined for that function                             }