Просмотр исходного кода

ft: 添加transaction 事务执行

master
SisMaker 4 месяцев назад
Родитель
Сommit
340c5fbf9e
1 измененных файлов: 3 добавлений и 4 удалений
  1. +3
    -4
      src/eGLock.erl

+ 3
- 4
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

Загрузка…
Отмена
Сохранить