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