2
0
Эх сурвалжийг харах

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

Nikolay Nikolov 1 жил өмнө
parent
commit
6d45fd09a2

+ 5 - 5
rtl/wasi/wasmmutex.inc

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