From 733d8651055751e1a037132476fc508a2e5be5c7 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 11 Apr 2024 17:57:21 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E4=BB=A3=E7=A0=81=E4=BF=AE=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eGLock.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/eGLock.erl b/src/eGLock.erl index 6e543e5..0bdb421 100644 --- a/src/eGLock.erl +++ b/src/eGLock.erl @@ -15,9 +15,9 @@ lockApply(KeyOrKeys, MFAOrFun) -> lockApply(KeyOrKeys, MFAOrFun, TimeOut) -> case KeyOrKeys of {_, _} -> - lockApply(KeyOrKeys, MFAOrFun, TimeOut, erlang:system_time(microsecond)); + lockApply(KeyOrKeys, MFAOrFun, TimeOut, erlang:system_time(millisecond)); _ -> - lockApplys(KeyOrKeys, MFAOrFun, TimeOut, erlang:system_time(microsecond)) + lockApplys(KeyOrKeys, MFAOrFun, TimeOut, erlang:system_time(millisecond)) end. -define(CASE(Cond, Then, That), case Cond of true -> Then; _ -> That end). @@ -38,7 +38,7 @@ lockApply(Key, MFAOrFun, TimeOut, FirstTime) -> ok end; _ -> - LTimeOut = ?CASE(TimeOut == infinity, TimeOut, max(0, TimeOut - max(erlang:system_time(microsecond) - FirstTime, 0))), + LTimeOut = ?CASE(TimeOut == infinity, TimeOut, max(0, TimeOut - max(erlang:system_time(millisecond) - FirstTime, 0))), receive ?ReTryLockApply -> lockApply(Key, MFAOrFun, TimeOut, FirstTime) @@ -64,7 +64,7 @@ lockApplys(Keys, MFAOrFun, TimeOut, FirstTime) -> ok end; _ -> - LTimeOut = ?CASE(TimeOut == infinity, TimeOut, max(0, TimeOut - max(erlang:system_time(microsecond) - FirstTime, 0))), + LTimeOut = ?CASE(TimeOut == infinity, TimeOut, max(0, TimeOut - max(erlang:system_time(millisecond) - FirstTime, 0))), receive ?ReTryLockApply -> lockApplys(Keys, MFAOrFun, TimeOut, FirstTime)