浏览代码

ft: 确保时间

master
SisMaker 1年前
父节点
当前提交
d749b95e73
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. +2
    -2
      src/eGLock.erl

+ 2
- 2
src/eGLock.erl 查看文件

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

正在加载...
取消
保存