瀏覽代碼

* WebAssembly mutex: treat all negative values of aTimeoutMS as infinite, instead of just -1

Nikolay Nikolov 1 年之前
父節點
當前提交
6d45fd09a2
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      rtl/wasi/wasmmutex.inc

+ 5 - 5
rtl/wasi/wasmmutex.inc

@@ -63,7 +63,7 @@ begin
 end;
 
 
-// aTimeOutNS is in milliseconds. -1 is infinite
+// aTimeOutMS is in milliseconds. <0 (e.g. -1) is infinite
 Function LockMutexTimeoutNoWait(var m : TWasmMutex; aTimeOutMS : LongInt) : TLockMutexResult;
 
 Var
@@ -74,7 +74,7 @@ Var
 begin
   {$IFDEF DEBUGWASMTHREADS}DebugWriteln('LockMutexTimeoutNoWait('+IntToStr(m.locked)+','+intToStr(aTimeOutMs)+')');{$ENDIF}
   Res:=lmrNone;
-  if aTimeOutMS<>-1 then
+  if aTimeOutMS>=0 then
     EndTime:=GetClockTime+aTimeOutMS*1000000
   else
     EndTime:=0;
@@ -89,7 +89,7 @@ begin
         Res:=lmrError
       else
         begin
-        If (aTimeOutMS<>-1) and (GetClockTime>EndTime) then
+        If (aTimeOutMS>=0) and (GetClockTime>EndTime) then
           Res:=lmrTimeOut
         end;
       end;
@@ -109,7 +109,7 @@ begin
   {$IFDEF DEBUGWASMTHREADS}DebugWriteln('LockMutexTimeoutWait('+IntToStr(m.locked)+','+intToStr(aTimeOutMs)+')');{$ENDIF}
   Res:=lmrNone;
   MyThread:=GetSelfThread;
-  if aTimeOutMS<>-1 then
+  if aTimeOutMS>=0 then
     EndTime:=GetClockTime+aTimeOutMS*1000000
   else
     EndTime:=0;
@@ -131,7 +131,7 @@ begin
             Res:=lmrError
           else
             begin
-            If (aTimeOutMS<>-1) and (GetClockTime>EndTime) then
+            If (aTimeOutMS>=0) and (GetClockTime>EndTime) then
               Res:=lmrTimeOut
             end;
           end;