#include <fio_TransGroupLock.h>

Definition at line 29 of file fio_TransGroupLock.h.
Public Member Functions | |
| fio_TransGroupLock (int a_hashSize, int a_groups) | |
| void | LockByIDOwn (const fio_LockEl_t &a_ID) |
| bool | CanLockByID (_T a_ID) |
| void | LockByID (_T a_ID) |
| bool | CanLockByIDOwn (fio_LockEl_t &a_ID) |
| void | UnLockByID (_T a_id) |
| void | UnLockByOwn (int a_groupID) |
| void | UnLockAndFlush (fio_Transaction &a_trans) |
| void | ReserveGroup (fio_Transaction *a_trans_p, int a_maxNumOfLocks, int a_maxWaitSeconds) |
| void | ReleaseGroup (fio_Transaction &a_trans) |
Public Attributes | |
| log_CLASSID_m | |
Private Types | |
| typedef cmn_IDOwn< _T > | fio_LockEl_t |
| typedef stx_GroupOfEl< _T, _defTransEl > | fio_ElemInTrans_v |
| typedef stx_Groups < fio_ElemInTrans_v, _T > | fio_TransGroupLock_t |
| typedef cmn_LockIDbyOwn< _T, 10 > | fio_LockEl_v |
| typedef cmn_LockIDHash < fio_LockEl_v, _T > | fio_Hash_t |
| typedef fio_TransGroupLock< _T, _defTransEl > ::fio_ElemInTrans_v::iterator | fio_ElemInTrans_i |
Private Attributes | |
| fio_Hash_t | m_hash |
| stx_XStack | m_freeGroups |
| fio_TransGroupLock_t | m_whoLockedElem |
typedef cmn_IDOwn<_T> fio_TransGroupLock< _T, _defTransEl >::fio_LockEl_t [private] |
Definition at line 30 of file fio_TransGroupLock.h.
typedef stx_GroupOfEl<_T, _defTransEl> fio_TransGroupLock< _T, _defTransEl >::fio_ElemInTrans_v [private] |
Definition at line 32 of file fio_TransGroupLock.h.
typedef stx_Groups<fio_ElemInTrans_v, _T> fio_TransGroupLock< _T, _defTransEl >::fio_TransGroupLock_t [private] |
Definition at line 33 of file fio_TransGroupLock.h.
typedef cmn_LockIDbyOwn<_T, 10> fio_TransGroupLock< _T, _defTransEl >::fio_LockEl_v [private] |
Definition at line 35 of file fio_TransGroupLock.h.
typedef cmn_LockIDHash<fio_LockEl_v, _T> fio_TransGroupLock< _T, _defTransEl >::fio_Hash_t [private] |
Definition at line 36 of file fio_TransGroupLock.h.
typedef fio_TransGroupLock<_T, _defTransEl>::fio_ElemInTrans_v::iterator fio_TransGroupLock< _T, _defTransEl >::fio_ElemInTrans_i [private] |
Definition at line 39 of file fio_TransGroupLock.h.
| fio_TransGroupLock< _T, _defTransEl >::fio_TransGroupLock | ( | int | a_hashSize, | |
| int | a_groups | |||
| ) | [inline] |
Definition at line 42 of file fio_TransGroupLock.h.
References log_FUNC_m, fio_TransGroupLock< _T, _defTransEl >::m_freeGroups, and stx_XStack::Push().
00043 : 00044 m_hash(a_hashSize), 00045 m_whoLockedElem(a_groups) 00046 { 00047 log_FUNC_m(fio_TransGroupLock) 00048 // reserve as many IDs as group count 00049 for (int j = a_groups - 1; j >= 0; j--) { 00050 m_freeGroups.Push(j); 00051 } 00052 }; log_CLASSID_m;

| void fio_TransGroupLock< _T, _defTransEl >::LockByIDOwn | ( | const fio_LockEl_t & | a_ID | ) | [inline] |
Definition at line 62 of file fio_TransGroupLock.h.
References cmn_LockIDbyOwn< _T, _size >::CanLockByIDOwnNoMutex(), dbg_DETAIL, elementIsNotLocked_d, fio_Transaction::EndTransaction(), stx_Groups< _G, _T >::GetGroup(), cmn_LockIDHash< _V, _T >::HashFunc(), stx_Groups< _G, _T >::InsertEl(), ivd_NULLCHK_m, cmn_LockIDHash< _V, _T >::LockByIDOwn(), log_DBG_m, log_FUNC_m, fio_TransGroupLock< _T, _defTransEl >::m_hash, cmn_IDOwn< _T >::m_id, cmn_IDOwn< _T >::m_ownerID, fio_TransGroupLock< _T, _defTransEl >::m_whoLockedElem, cmn_LockIDbyOwn< _T, _size >::ReleaseMutex(), s_className, cmn_LockIDbyOwn< _T, _size >::SetMutex(), fio_Transaction::StartTransaction(), and fio_TransGroupLock< _T, _defTransEl >::UnLockByOwn().
00062 { 00063 log_FUNC_m(LockByIDOwn) 00064 // get vector that hold a lock of element 00065 fio_LockEl_v &lockVec = m_hash.HashFunc(a_ID); 00066 lockVec.SetMutex(); 00067 // return the ownerID if element is locket othervice 0 and lock it 00068 int elemOwner = lockVec.CanLockByIDOwnNoMutex(a_ID); 00069 if (elemOwner == elementIsNotLocked_d) { 00070 m_whoLockedElem.InsertEl(a_ID.m_ownerID, a_ID.m_id); 00071 } 00072 else if (elemOwner != a_ID.m_ownerID) { 00073 log_DBG_m(dbg_DETAIL, "Element " << a_ID << " is locked by another owner " << elemOwner); 00074 if (elemOwner >= 0) { // then element is hold by multy element transaction 00075 // othervise only one element is locked with no owner 00076 // owner of locked element can't gone away its element is still locked by hash 00077 // send message "release locked elements" to owner 00078 m_whoLockedElem.GetGroup(elemOwner).GetOwner()->SetNeedFlush(); 00079 } 00080 lockVec.ReleaseMutex(); // release the lock vector, that owner can unlock element 00081 // fio_Transaction* trans = reinterpret_cast<fio_Transaction*> 00082 // fix bug 699 00083 fio_Transaction* trans = dynamic_cast<fio_Transaction*> 00084 (m_whoLockedElem.GetGroup(a_ID.m_ownerID).GetOwner()); 00085 ivd_NULLCHK_m(trans, fio_Transaction::s_className); 00086 // flush current transaction in meantime 00087 trans->EndTransaction(); 00088 UnLockByOwn(a_ID.m_ownerID); // release all locked elements 00089 trans->StartTransaction(); 00090 // owner is anounced. Current transaction is flushed, 00091 // so it doesn't hold locked elements. 00092 // Now wait for lock element by itself. 00093 m_hash.LockByIDOwn(a_ID); 00094 m_whoLockedElem.InsertEl(a_ID.m_ownerID, a_ID.m_id); 00095 return; // already unlocked 00096 } 00097 lockVec.ReleaseMutex(); 00098 };

| bool fio_TransGroupLock< _T, _defTransEl >::CanLockByID | ( | _T | a_ID | ) | [inline] |
Definition at line 100 of file fio_TransGroupLock.h.
References cmn_LockIDHash< _V, _T >::CanLockByID(), and fio_TransGroupLock< _T, _defTransEl >::m_hash.
00100 { 00101 return m_hash.CanLockByID(a_ID); 00102 };

| void fio_TransGroupLock< _T, _defTransEl >::LockByID | ( | _T | a_ID | ) | [inline] |
Definition at line 104 of file fio_TransGroupLock.h.
References cmn_LockIDHash< _V, _T >::LockByID(), and fio_TransGroupLock< _T, _defTransEl >::m_hash.

| bool fio_TransGroupLock< _T, _defTransEl >::CanLockByIDOwn | ( | fio_LockEl_t & | a_ID | ) | [inline] |
Definition at line 108 of file fio_TransGroupLock.h.
References cmn_LockIDHash< _V, _T >::CanLockByIDOwn(), eLckOtherOwn, eLckSameOwn, eLocked, eNotLocked, stx_Groups< _G, _T >::InsertEl(), fio_TransGroupLock< _T, _defTransEl >::m_hash, cmn_IDOwn< _T >::m_id, cmn_IDOwn< _T >::m_ownerID, and fio_TransGroupLock< _T, _defTransEl >::m_whoLockedElem.
00108 { 00109 switch (m_hash.CanLockByIDOwn(a_ID)) { 00110 case eNotLocked : 00111 m_whoLockedElem.InsertEl(a_ID.m_ownerID, a_ID.m_id); 00112 return true; 00113 break; 00114 case eLckSameOwn : 00115 return true; 00116 break; 00117 case eLckOtherOwn : 00118 return false; 00119 case eLocked : 00120 return false; 00121 break; 00122 default: 00123 return false; 00124 break; 00125 } 00126 };

| void fio_TransGroupLock< _T, _defTransEl >::UnLockByID | ( | _T | a_id | ) | [inline] |
Definition at line 128 of file fio_TransGroupLock.h.
References fio_TransGroupLock< _T, _defTransEl >::m_hash, and cmn_LockIDHash< _V, _T >::UnLockByID().
00128 { 00129 m_hash.UnLockByID(a_id); 00130 };

| void fio_TransGroupLock< _T, _defTransEl >::UnLockByOwn | ( | int | a_groupID | ) | [inline] |
Definition at line 132 of file fio_TransGroupLock.h.
References stx_GroupOfEl< _T, _defGroupEl >::Clear(), stx_Groups< _G, _T >::GetGroup(), fio_TransGroupLock< _T, _defTransEl >::m_hash, fio_TransGroupLock< _T, _defTransEl >::m_whoLockedElem, and cmn_LockIDHash< _V, _T >::UnLockByID().
Referenced by fio_TransGroupLock< _T, _defTransEl >::LockByIDOwn(), fio_TransGroupLock< _T, _defTransEl >::ReleaseGroup(), and fio_TransGroupLock< _T, _defTransEl >::UnLockAndFlush().
00132 { 00133 fio_ElemInTrans_v &group = m_whoLockedElem.GetGroup(a_groupID); 00134 for (fio_ElemInTrans_i iter = group.begin(); iter != group.end(); iter++) { 00135 m_hash.UnLockByID(*iter); 00136 } 00137 group.Clear(); 00138 };


| void fio_TransGroupLock< _T, _defTransEl >::UnLockAndFlush | ( | fio_Transaction & | a_trans | ) | [inline] |
Definition at line 140 of file fio_TransGroupLock.h.
References dbg_DETAIL, fio_Transaction::EndTransaction(), cmn_LockOwn::GetGroupID(), log_DBG_m, log_FUNC_m, and fio_TransGroupLock< _T, _defTransEl >::UnLockByOwn().
00140 { 00141 log_FUNC_m(UnLockAndFlush) 00142 log_DBG_m(dbg_DETAIL, "Owner " << a_trans.GetGroupID() << " will flush and unlock."); 00143 a_trans.EndTransaction(); 00144 UnLockByOwn(a_trans.GetGroupID()); 00145 //FIX 634 a_trans.StartTransaction(); 00146 };

| void fio_TransGroupLock< _T, _defTransEl >::ReserveGroup | ( | fio_Transaction * | a_trans_p, | |
| int | a_maxNumOfLocks, | |||
| int | a_maxWaitSeconds | |||
| ) | [inline] |
Definition at line 149 of file fio_TransGroupLock.h.
References stx_Groups< _G, _T >::GetGroup(), cmn_LockOwn::LockOwnInit(), log_FUNC_m, fio_TransGroupLock< _T, _defTransEl >::m_freeGroups, fio_TransGroupLock< _T, _defTransEl >::m_whoLockedElem, and stx_XStack::Pop().
00151 { 00152 log_FUNC_m(ReserveGroup) 00153 int grpID = m_freeGroups.Pop(); 00154 a_trans_p->LockOwnInit(grpID, a_maxNumOfLocks, a_maxWaitSeconds); 00155 m_whoLockedElem.GetGroup(grpID).SetOwner(a_trans_p); 00156 //FIX 634 a_trans_p->StartTransaction(); 00157 };

| void fio_TransGroupLock< _T, _defTransEl >::ReleaseGroup | ( | fio_Transaction & | a_trans | ) | [inline] |
Definition at line 159 of file fio_TransGroupLock.h.
References fio_Transaction::EndTransIfStarted(), cmn_LockOwn::GetGroupID(), log_FUNC_m, fio_TransGroupLock< _T, _defTransEl >::m_freeGroups, stx_XStack::Push(), and fio_TransGroupLock< _T, _defTransEl >::UnLockByOwn().
00159 { 00160 log_FUNC_m(ReleaseGroup) 00161 a_trans.EndTransIfStarted(); 00162 //FIX 634 a_trans.EndTransaction(); 00163 UnLockByOwn(a_trans.GetGroupID()); 00164 m_freeGroups.Push(a_trans.GetGroupID()); 00165 };

| fio_TransGroupLock< _T, _defTransEl >::log_CLASSID_m |
Definition at line 52 of file fio_TransGroupLock.h.
fio_Hash_t fio_TransGroupLock< _T, _defTransEl >::m_hash [private] |
Definition at line 57 of file fio_TransGroupLock.h.
Referenced by fio_TransGroupLock< _T, _defTransEl >::CanLockByID(), fio_TransGroupLock< _T, _defTransEl >::CanLockByIDOwn(), fio_TransGroupLock< _T, _defTransEl >::LockByID(), fio_TransGroupLock< _T, _defTransEl >::LockByIDOwn(), fio_TransGroupLock< _T, _defTransEl >::UnLockByID(), and fio_TransGroupLock< _T, _defTransEl >::UnLockByOwn().
stx_XStack fio_TransGroupLock< _T, _defTransEl >::m_freeGroups [private] |
Definition at line 58 of file fio_TransGroupLock.h.
Referenced by fio_TransGroupLock< _T, _defTransEl >::fio_TransGroupLock(), fio_TransGroupLock< _T, _defTransEl >::ReleaseGroup(), and fio_TransGroupLock< _T, _defTransEl >::ReserveGroup().
fio_TransGroupLock_t fio_TransGroupLock< _T, _defTransEl >::m_whoLockedElem [private] |
1.5.6