Browse Source

ft: 确保时间

master
SisMaker 1 year ago
parent
commit
d749b95e73
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/eGLock.erl

+ 2
- 2
src/eGLock.erl View File

@ -44,7 +44,7 @@ lockApply(Key, MFAOrFun, TimeOut, LastTime) ->
lockApply(Key, MFAOrFun, TimeOut, LastTime);
_ ->
CurTime = erlang:system_time(microsecond),
NewTimeOut = TimeOut - max(CurTime - LastTime, 0),
NewTimeOut = max(0, TimeOut - max(CurTime - LastTime, 0)),
lockApply(Key, MFAOrFun, NewTimeOut, CurTime)
end
after TimeOut ->
@ -76,7 +76,7 @@ lockApplys(Keys, MFAOrFun, TimeOut, LastTime) ->
lockApplys(Keys, MFAOrFun, TimeOut, LastTime);
_ ->
CurTime = erlang:system_time(microsecond),
NewTimeOut = TimeOut - max(CurTime - LastTime, 0),
NewTimeOut = max(0, TimeOut - max(CurTime - LastTime, 0)),
lockApplys(Keys, MFAOrFun, NewTimeOut, CurTime)
end
after TimeOut ->

Loading…
Cancel
Save