瀏覽代碼

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);
_ ->
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…
取消
儲存