Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

fio_TransLstMgr Class Reference
[Classes for large file i/o, relative file, and DataBase]

#include <fio_TransLstMgr.h>

Collaboration diagram for fio_TransLstMgr:
Collaboration graph
[legend]

List of all members.

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_TransactionGetTransObj ()
 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_DataBasem_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

Detailed Description

Definition at line 58 of file fio_TransLstMgr.h.


Constructor & Destructor Documentation

fio_TransLstMgr::fio_TransLstMgr (  ) 

Definition at line 75 of file fio_TransLstMgr.cpp.

References log_FUNC_m.

fio_TransLstMgr::~fio_TransLstMgr (  )  [virtual]

Definition at line 81 of file fio_TransLstMgr.cpp.

References CleanUp(), and log_FUNC_m.

Here is the call graph for this function:


Member Function Documentation

void fio_TransLstMgr::CleanUp (  )  [inline, private]

Definition at line 111 of file fio_TransLstMgr.cpp.

References ClearTransPtrVector(), and log_FUNC_m.

Referenced by Init(), and ~fio_TransLstMgr().

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_TransLstMgr::ClearTransPtrVector (  )  [private]

Definition at line 118 of file fio_TransLstMgr.cpp.

References log_FUNC_m, and m_transaction_p_v.

Referenced by CleanUp().

                                          {
    log_FUNC_m(ClearTransPtrVector);
    fio_Transaction_p_v_t::iterator p;
    for (p = m_transaction_p_v.begin(); p != m_transaction_p_v.end(); p++) {
//        if (*p != NULL) {
            delete (*p);
//        }
    }
    m_transaction_p_v.clear();
}

Here is the caller graph for this function:

unsigned int fio_TransLstMgr::GetSizeOfLoUTID (  )  [inline]

return the number of free transactions

Definition at line 112 of file fio_TransLstMgr.h.

{ return m_LoUTID_v.size(); };

fio_Transaction * fio_TransLstMgr::GetTransObj (  ) 

return first free transaction.

Definition at line 131 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, s_className, and cmn_Mutex::Unlock().

                                              {
    log_FUNC_m(GetTransObj);

    fio_Transaction* p = NULL;
    m_transLstMgr_x.Lock();
    // IF List of unused transaction IDs is not empty
    if (m_LoUTID_v.size() > 0) {
        // get free index and then use it to get pointer of transaction
        p = m_transaction_p_v[m_LoUTID_v.back() - 1];
        m_LoUTID_v.pop_back();
    }
    else {  // in case, no free transaction available, new one is created
        int transID = m_transaction_p_v.size() + 1;
        p = new fio_Transaction(m_db_p, transID); // vector size is new transactionID
        ivd_NULLCHK_m(p, fio_Transaction::s_className);

        m_transaction_p_v.push_back(p);

        unsigned int transCount = m_transaction_p_v.size();

        if ( transCount > 1024 ) {
            m_transLstMgr_x.Unlock();
            throw ivd_InternalError(ie_TRANS_TO_MUCH_INSTANCES, "Exaggerated number of transaction instances. > 1024", true);
        }

        if ( transCount % 200 == 0 ) {
            log_WRN_m("Strange high number of transaction instances. " << transCount );
        }
    }
    m_transLstMgr_x.Unlock();
    return p;
}

Here is the call graph for this function:

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 88 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().

                                                                {

    log_FUNC_m(Init);

    m_db_p = a_db_p;  // set the database

    fio_Transaction *p;  
    // open few transaction for future use
    for (unsigned int i = a_numOfTrans; i > 0;  i--) {
        p = new fio_Transaction(a_db_p, i);
        if (p == NULL) {
            CleanUp();
            ivd_NULLCHK_m(p, fio_Transaction::s_className);
        }

        m_transaction_p_v.push_back(p);
        m_LoUTID_v.push_back(i); // all transaction are available to use
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fio_TransLstMgr::isTransRegistered ( fio_Transaction a_trans_p  )  [inline]

Check if transaction belong to this list.

Definition at line 106 of file fio_TransLstMgr.h.

References fio_Transaction::GetTransID().

Referenced by ReleaseTransObj().

                                                       {
        // transaction ID - 1 is a vector index. Mutex is not need.
        return (a_trans_p == m_transaction_p_v[a_trans_p->GetTransID() - 1]); 
    };

Here is the call graph for this function:

Here is the caller graph for this function:

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 166 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().

                                                                 {
    log_FUNC_m(ReleaseTransObj);

    if ( (*a_trans_p != NULL)
       && isTransRegistered(*a_trans_p)) {
        m_transLstMgr_x.Lock();
        m_LoUTID_v.push_back((*a_trans_p)->GetTransID());
        m_transLstMgr_x.Unlock();
        *a_trans_p = NULL;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_TransLstMgr::ReleaseTransObj ( fio_Transaction a_trans  ) 

Member Data Documentation

Macro to add class name member s_className.

Definition at line 86 of file fio_TransLstMgr.h.

Definition at line 72 of file fio_TransLstMgr.h.

Referenced by GetTransObj(), and Init().

List of unused transaction IDs.

Definition at line 79 of file fio_TransLstMgr.h.

Referenced by GetTransObj(), Init(), and ReleaseTransObj().

vector of prepared transaction for use or already in use transactionID - 1 match the vector index.

Definition at line 76 of file fio_TransLstMgr.h.

Referenced by ClearTransPtrVector(), GetTransObj(), and Init().

mutex to transaction list manager members

Definition at line 82 of file fio_TransLstMgr.h.

Referenced by GetTransObj(), and ReleaseTransObj().


The documentation for this class was generated from the following files: