From bc877917d44376b803620795e5487878032e817d Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Tue, 17 Dec 2024 17:49:06 +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 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/eGLock.erl b/src/eGLock.erl index ecca3a6..f9df23c 100644 --- a/src/eGLock.erl +++ b/src/eGLock.erl @@ -124,13 +124,13 @@ lockApply(KeyOrKeys, MFAOrFun, TimeOut) -> true -> try doApply(MFAOrFun) catch C:R:S -> - {error, {lockApplyError, {C, R, S}}} + error({lockApplyError, KeyOrKeys, MFAOrFun, {C, R, S}}) after eNifLock:releaseLocks(KeyIxs), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, KeyOrKeys, MFAOrFun}) end; _ -> KeyIx = erlang:phash2(KeyOrKeys, ?eGLockSize), @@ -138,13 +138,13 @@ lockApply(KeyOrKeys, MFAOrFun, TimeOut) -> true -> try doApply(MFAOrFun) catch C:R:S -> - {error, {lockApplyError, {KeyOrKeys, MFAOrFun}, {C, R, S}}} + error({lockApplyError, KeyOrKeys, MFAOrFun, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, KeyOrKeys, MFAOrFun}) end end. @@ -170,13 +170,13 @@ lockGet({?undefTab, Key = GetKey}, TimeOut) -> try #{{?undefTab, GetKey} => undefined} catch C:R:S -> - {error, {lockGetError, {?undefTab, Key}, {C, R, S}}} + error({lockGetError, {?undefTab, Key}, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, {?undefTab, Key}}) end; lockGet({EtsTab, Key} = GetKey, TimeOut) -> KeyIx = erlang:phash2(GetKey, ?eGLockSize), @@ -185,13 +185,13 @@ lockGet({EtsTab, Key} = GetKey, TimeOut) -> try #{GetKey => getEtsTabValue(EtsTab, Key, undefined)} catch C:R:S -> - {error, {lockGetError, GetKey, {C, R, S}}} + error({lockGetError, GetKey, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, GetKey}) end; lockGet({?undefTab, Key = GetKey, DefValue}, TimeOut) -> KeyIx = erlang:phash2(GetKey, ?eGLockSize), @@ -200,13 +200,13 @@ lockGet({?undefTab, Key = GetKey, DefValue}, TimeOut) -> try #{{?undefTab, GetKey} => getDefValue(DefValue)} catch C:R:S -> - {error, {lockGetError, {?undefTab, Key, DefValue}, {C, R, S}}} + error({lockGetError, {?undefTab, Key, DefValue}, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, {?undefTab, Key, DefValue}}) end; lockGet({EtsTab, Key, DefValue}, TimeOut) -> GetKey = {EtsTab, Key}, @@ -216,13 +216,13 @@ lockGet({EtsTab, Key, DefValue}, TimeOut) -> try #{GetKey => getEtsTabValue(EtsTab, Key, DefValue)} catch C:R:S -> - {error, {lockGetError, {EtsTab, Key, DefValue}, {C, R, S}}} + error({lockGetError, {EtsTab, Key, DefValue}, {C, R, S}}) after eNifLock:releaseLock(KeyIx), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, {EtsTab, Key, DefValue}}) end; lockGet(EtsTabKeys, TimeOut) -> {KeyIxs, KeysMap} = getKeyIxAndMaps(EtsTabKeys, [], #{}), @@ -231,13 +231,13 @@ lockGet(EtsTabKeys, TimeOut) -> try #{OneGetKey => getEtsTabValue(OneEtsTab, OneKey, OneDefValue) || {OneEtsTab, OneKey} = OneGetKey := OneDefValue <- KeysMap} catch C:R:S -> - {error, {lockGetError, EtsTabKeys, {C, R, S}}} + error({lockGetError, EtsTabKeys, {C, R, S}}) after eNifLock:releaseLocks(KeyIxs), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, EtsTabKeys}) end. getKeyIxAndMaps([], IxAcc, KeysMap) -> {IxAcc, KeysMap}; @@ -290,13 +290,13 @@ transaction(EtsTabKeys, MFAOrFun, TimeOut) -> catch throw:Throw -> Throw; C:R:S -> - {error, {lockTransactionError, {MFAOrFun, EtsTabKeys}, {C, R, S}}} + error({lockTransactionError, EtsTabKeys, MFAOrFun, {C, R, S}}) after eNifLock:releaseLocks(KeyIxs), ok end; lockTimeout -> - {error, lockTimeout} + error({lockTimeout, EtsTabKeys, MFAOrFun}) end. getDefValue(undefined) -> undefined;