#include <fio_TransLstMgr.h>

Definition at line 44 of file fio_TransLstMgr.h.
Public Member Functions | |
| fio_TransLstMgr () | |
| virtual | ~fio_TransLstMgr () |
| void | Init (fio_DataBase *a_db_p, unsigned int a_numOfTrans) |
| To initialize the instance, specially as database member. | |
| fio_Transaction * | GetTransObj () |
| return first free transaction. | |
| void | ReleaseTransObj (fio_Transaction **a_trans_p) |
| transaction is not used any more. | |
| void | ReleaseTransObj (fio_Transaction &a_trans) |
| bool | isTransRegistered (fio_Transaction *a_trans_p) |
| Check if transaction belong to this list. | |
| unsigned int | GetSizeOfLoUTID () |
| return the number of free transactions | |
Public Attributes | |
| log_CLASSID_m | |
| Macro to add class name member s_className. | |
Private Member Functions | |
| void | CleanUp () |
| void | ClearTransPtrVector () |
Private Attributes | |
| fio_DataBase * | m_db_p |
| fio_Transaction_p_v_t | m_transaction_p_v |
| vector of prepared transaction for use or already in use transactionID - 1 match the vector index. | |
| fio_TransactionID_v_t | m_LoUTID_v |
| List of unused transaction IDs. | |
| cmn_Mutex | m_transLstMgr_x |
| mutex to transaction list manager members | |
| fio_TransLstMgr::fio_TransLstMgr | ( | ) |
Definition at line 61 of file fio_TransLstMgr.cpp.
References log_FUNC_m.
00061 { 00062 log_FUNC_m(fio_TransLstMgr); 00063 }
| fio_TransLstMgr::~fio_TransLstMgr | ( | ) | [virtual] |
Definition at line 67 of file fio_TransLstMgr.cpp.
References CleanUp(), and log_FUNC_m.
00067 { 00068 log_FUNC_m(~fio_TransLstMgr); 00069 CleanUp(); 00070 }

| void fio_TransLstMgr::Init | ( | fio_DataBase * | a_db_p, | |
| unsigned int | a_numOfTrans | |||
| ) |
To initialize the instance, specially as database member.
It is not possible to construct it directlly, cause it is database member that should be constructed in database base member initializer list, and use database pointer at the same time, which is not safe, because not all member of database were creted yet.
Definition at line 74 of file fio_TransLstMgr.cpp.
References CleanUp(), ivd_NULLCHK_m, log_FUNC_m, m_db_p, m_LoUTID_v, m_transaction_p_v, NULL, and s_className.
Referenced by fio_DataBase::fio_DataBase().
00075 { 00076 00077 log_FUNC_m(Init); 00078 00079 m_db_p = a_db_p; // set the database 00080 00081 fio_Transaction *p; 00082 // open few transaction for future use 00083 for (unsigned int i = a_numOfTrans; i > 0; i--) { 00084 p = new fio_Transaction(a_db_p, i); 00085 if (p == NULL) { 00086 CleanUp(); 00087 ivd_NULLCHK_m(p, fio_Transaction::s_className); 00088 } 00089 00090 m_transaction_p_v.push_back(p); 00091 m_LoUTID_v.push_back(i); // all transaction are available to use 00092 } 00093 }


| fio_Transaction * fio_TransLstMgr::GetTransObj | ( | ) |
return first free transaction.
Definition at line 117 of file fio_TransLstMgr.cpp.
References ie_TRANS_TO_MUCH_INSTANCES, ivd_NULLCHK_m, cmn_Mutex::Lock(), log_FUNC_m, log_WRN_m, m_db_p, m_LoUTID_v, m_transaction_p_v, m_transLstMgr_x, NULL, s_className, and cmn_Mutex::Unlock().
00117 { 00118 log_FUNC_m(GetTransObj); 00119 00120 fio_Transaction* p = NULL; 00121 m_transLstMgr_x.Lock(); 00122 // IF List of unused transaction IDs is not empty 00123 if (m_LoUTID_v.size() > 0) { 00124 // get free index and then use it to get pointer of transaction 00125 p = m_transaction_p_v[m_LoUTID_v.back() - 1]; 00126 m_LoUTID_v.pop_back(); 00127 } 00128 else { // in case, no free transaction available, new one is created 00129 int transID = m_transaction_p_v.size() + 1; 00130 p = new fio_Transaction(m_db_p, transID); // vector size is new transactionID 00131 ivd_NULLCHK_m(p, fio_Transaction::s_className); 00132 00133 m_transaction_p_v.push_back(p); 00134 00135 unsigned int transCount = m_transaction_p_v.size(); 00136 00137 if ( transCount > 1024 ) { 00138 m_transLstMgr_x.Unlock(); 00139 throw ivd_InternalError(ie_TRANS_TO_MUCH_INSTANCES, "Exaggerated number of transaction instances. > 1024", true); 00140 } 00141 00142 if ( transCount % 200 == 0 ) { 00143 log_WRN_m("Strange high number of transaction instances. " << transCount ); 00144 } 00145 } 00146 m_transLstMgr_x.Unlock(); 00147 return p; 00148 }

| void fio_TransLstMgr::ReleaseTransObj | ( | fio_Transaction ** | a_trans_p | ) |
transaction is not used any more.
It is released for other user. the pointer is set to NULL;
Definition at line 152 of file fio_TransLstMgr.cpp.
References isTransRegistered(), cmn_Mutex::Lock(), log_FUNC_m, m_LoUTID_v, m_transLstMgr_x, NULL, and cmn_Mutex::Unlock().
Referenced by ReleaseTransObj().
00152 { 00153 log_FUNC_m(ReleaseTransObj); 00154 00155 if ( (*a_trans_p != NULL) 00156 && isTransRegistered(*a_trans_p)) { 00157 m_transLstMgr_x.Lock(); 00158 m_LoUTID_v.push_back((*a_trans_p)->GetTransID()); 00159 m_transLstMgr_x.Unlock(); 00160 *a_trans_p = NULL; 00161 } 00162 }


| void fio_TransLstMgr::ReleaseTransObj | ( | fio_Transaction & | a_trans | ) |
Definition at line 166 of file fio_TransLstMgr.cpp.
References fio_Transaction::GetTransID(), isTransRegistered(), cmn_Mutex::Lock(), log_FUNC_m, m_LoUTID_v, m_transLstMgr_x, ReleaseTransObj(), and cmn_Mutex::Unlock().
00166 { 00167 log_FUNC_m(ReleaseTransObj); 00168 00169 if (isTransRegistered(&a_trans)) { 00170 m_transLstMgr_x.Lock(); 00171 m_LoUTID_v.push_back(a_trans.GetTransID()); 00172 m_transLstMgr_x.Unlock(); 00173 } 00174 }

| bool fio_TransLstMgr::isTransRegistered | ( | fio_Transaction * | a_trans_p | ) | [inline] |
Check if transaction belong to this list.
Definition at line 92 of file fio_TransLstMgr.h.
References fio_Transaction::GetTransID().
Referenced by ReleaseTransObj().
00092 { 00093 // transaction ID - 1 is a vector index. Mutex is not need. 00094 return (a_trans_p == m_transaction_p_v[a_trans_p->GetTransID() - 1]); 00095 };


| unsigned int fio_TransLstMgr::GetSizeOfLoUTID | ( | ) | [inline] |
return the number of free transactions
Definition at line 98 of file fio_TransLstMgr.h.
00098 { return m_LoUTID_v.size(); };
| void fio_TransLstMgr::CleanUp | ( | ) | [inline, private] |
Definition at line 97 of file fio_TransLstMgr.cpp.
References ClearTransPtrVector(), and log_FUNC_m.
Referenced by Init(), and ~fio_TransLstMgr().
00097 { 00098 log_FUNC_m(CleanUp); 00099 ClearTransPtrVector(); 00100 }


| void fio_TransLstMgr::ClearTransPtrVector | ( | ) | [private] |
Definition at line 104 of file fio_TransLstMgr.cpp.
References log_FUNC_m, and m_transaction_p_v.
Referenced by CleanUp().
00104 { 00105 log_FUNC_m(ClearTransPtrVector); 00106 fio_Transaction_p_v_t::iterator p; 00107 for (p = m_transaction_p_v.begin(); p != m_transaction_p_v.end(); p++) { 00108 // if (*p != NULL) { 00109 delete (*p); 00110 // } 00111 } 00112 m_transaction_p_v.clear(); 00113 }

fio_DataBase* fio_TransLstMgr::m_db_p [private] |
vector of prepared transaction for use or already in use transactionID - 1 match the vector index.
Definition at line 62 of file fio_TransLstMgr.h.
Referenced by ClearTransPtrVector(), GetTransObj(), and Init().
List of unused transaction IDs.
Definition at line 65 of file fio_TransLstMgr.h.
Referenced by GetTransObj(), Init(), and ReleaseTransObj().
cmn_Mutex fio_TransLstMgr::m_transLstMgr_x [private] |
mutex to transaction list manager members
Definition at line 68 of file fio_TransLstMgr.h.
Referenced by GetTransObj(), and ReleaseTransObj().
1.5.6