From 340c5fbf9ed2f99a5aa7bf53106609e264607172 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Tue, 17 Dec 2024 18:24:58 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E6=B7=BB=E5=8A=A0transaction=20=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eGLock.erl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/eGLock.erl b/src/eGLock.erl index f9df23c..d59a905 100644 --- a/src/eGLock.erl +++ b/src/eGLock.erl @@ -9,7 +9,6 @@ -define(ReTryTime, 3). %% 数组数量 -define(eGLockSize, 2097152). - %% 没有ets 表的key -define(undefTab, undefTab). @@ -111,7 +110,7 @@ getLockPid(KeyOrKeys) -> {KeyOrKeys, eNifLock:getLockPid(erlang:phash2(KeyOrKeys, ?eGLockSize))} end. --spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}) -> term() | {error, lockTimeout} | {error, {lockApplyError, term()}}. +-spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}) -> term(). lockApply(KeyOrKeys, MFAOrFun) -> lockApply(KeyOrKeys, MFAOrFun, ?LockTimeOut). @@ -158,11 +157,11 @@ doApply({M, F, Args}) -> doApply({Fun, Args}) -> apply(Fun, Args). --spec lockGet(KeyOrKeys :: term() | [term()]) -> ok. +-spec lockGet(KeyOrKeys :: term() | [term()]) -> map(). lockGet(KeyOrKeys) -> lockGet(KeyOrKeys, ?LockTimeOut). --spec lockGet(KeyOrKeys :: term() | [term()], TimeOut :: integer() | infinity) -> ok. +-spec lockGet(KeyOrKeys :: term() | [term()], TimeOut :: integer() | infinity) -> map(). lockGet({?undefTab, Key = GetKey}, TimeOut) -> KeyIx = erlang:phash2(GetKey, ?eGLockSize), case doTryLock(KeyIx, TimeOut) of