Public Member Functions | Private Attributes

cmn_Mutex Class Reference
[Common, basic classes, functions and types]

Mutex Class implemented in cmn_thread.cpp. More...

#include <thread.h>

List of all members.

Public Member Functions

 cmn_Mutex ()
virtual ~cmn_Mutex ()
void Lock ()
void Unlock ()

Private Attributes

 log_CLASSID_m

Detailed Description

Mutex Class implemented in cmn_thread.cpp.

Definition at line 59 of file thread.h.


Constructor & Destructor Documentation

cmn_Mutex::cmn_Mutex (  )  [inline]

Definition at line 63 of file thread.h.

    : omni_mutex(), m_tid(0) {
#else
    : omni_mutex() {
#endif
        // Empty
    };

cmn_Mutex::~cmn_Mutex (  )  [virtual]

Definition at line 247 of file cmn_thread.cpp.

References cmn_Num2Str(), ie_MUTEX, and ivd_GETTID.

                      {

#ifdef ivd_THREAD_DEBUG_d

    register ivd_ThreadID_t tid = ivd_GETTID();

    if (m_tid == tid) {
        omni_mutex::unlock();

        throw ivd_InternalError(ie_MUTEX,
            "Mutex still locked in destructor. tid = " +
            cmn_Num2Str((UInt32_t)m_tid));
    }
#endif
}

Here is the call graph for this function:


Member Function Documentation

void cmn_Mutex::Lock (  ) 

Definition at line 141 of file cmn_thread.cpp.

References cmn_Num2Str(), ie_MUTEX, ivd_GETTID, log_FUNC_m, and OMNITHREAD_EXEC_m.

Referenced by i_HSM_i::CompleteMigration(), fio_JourFile::DecRefCount(), i_HSM_i::DoMigrationJob(), i_HSM_i::EfficientRecall(), fio_DataBase::EndTransaction(), fio_RelFile::GetFirstNewIDX(), fio_JourMgr::GetJourReadHandle(), fio_JourMgr::GetJourWriteHandle(), fio_TransLstMgr::GetTransObj(), fio_RelFile::GetUnusedVectorIDX(), fio_JourMgr::IncTransNumber(), i_FSC_i::IVDFSRecovery(), hsm_JobElemVecMgr::JobToSequence(), fio_DataBase::LockDB(), hsm_FHmigc::Migrate(), fio_CirFileTrans::ReadFront(), fio_CirFileTrans::ReadNext(), hsm_FHADPRecall::RecallFilesFromList(), fio_DataBase::RegularSuspend(), fio_TransLstMgr::ReleaseTransObj(), fio_RelFile::ReleaseVector(), fio_JourMgr::ReleaseWaiters(), fsc_DataLMgr::Remove(), hsm_TimedList::Run(), hsm_FHmigc::Run(), hsm_FHADPRecall::Run(), hsm_FHmigc::SendToPM(), fio_PermDBinfoMgr::SetJourDate(), fio_PermDBinfoMgr::SetLastSyncPosition(), fio_PermDBinfoMgr::SetLastTransaction(), cmn_LockIDbyOwn< _T, _size >::SetMutex(), rm_ColMediaVol::StartSelectAll(), rm_MinorCol::StartSelectAll(), rm_MajorCol::StartSelectAll(), rm_Partition::StartSelectAll(), rm_MediumVol::StartSelectAll(), rm_Medium::StartSelectAll(), rm_Slot::StartSelectAll(), rm_MediaPool::StartSelectAll(), rm_DiskSubsys::StartSelectAll(), rm_DriveHost::StartSelectAll(), rm_Drive::StartSelectAll(), rm_Library::StartSelectAll(), fio_DataBase::StartTransaction(), hsm_FHdirty::TaskTime(), hsm_DirWaitList::TaskTime(), hsm_FHrelc::TruncationCheck(), fio_DataBase::UnlockDB(), fio_CirFileTrans::WriteBack(), fio_RelFile::WriteRec(), and fio_DataBase::~fio_DataBase().

                     {

#ifdef ivd_THREAD_DEBUG_d

    register ivd_ThreadID_t tid = ivd_GETTID();

    if (tid == m_tid) {
        // This thread has already locked the mutex. Just throw an exception.
        log_FUNC_m(Lock);
        throw ivd_InternalError(ie_MUTEX,
            "Double lock on mutex. tid = " +
            cmn_Num2Str((UInt32_t)tid));
    }
#endif
    int retval(0);
    OMNITHREAD_EXEC_m(Lock, lock());
//    OMNITHREAD_EXEC_m(Lock, retval = lock());

    if (retval != 0) {
        log_FUNC_m(Lock);
        register ivd_ThreadID_t tid = ivd_GETTID();
        ostringstream sstr;
        sstr
            << "Possible lock of already locked mutex. "
            << "Lock returned error number: " << retval
            << " for thread: " << tid;
        throw ivd_InternalError(ie_MUTEX, sstr.str());
    }

#ifdef ivd_THREAD_DEBUG_d
    if (m_tid != 0) {
        // Some thread has already locked the mutex. Just throw an exception.
        log_FUNC_m(Lock);
        throw ivd_InternalError(ie_MUTEX,
            "Double lock on mutex. tid = " +
            cmn_Num2Str((UInt32_t)m_tid));
    }
    // Remember the thread ID that locked mutex.
    m_tid = tid;
#endif
}

Here is the call graph for this function:

void cmn_Mutex::Unlock (  ) 

Definition at line 183 of file cmn_thread.cpp.

References cmn_Num2Str(), ie_MUTEX, ivd_GETTID, log_FUNC_m, and OMNITHREAD_EXEC_m.

Referenced by i_HSM_i::CompleteMigration(), fio_JourFile::DecRefCount(), i_HSM_i::DoMigrationJob(), i_HSM_i::EfficientRecall(), rm_ColMediaVol::EndSelectAll(), rm_MinorCol::EndSelectAll(), rm_MajorCol::EndSelectAll(), rm_Partition::EndSelectAll(), rm_MediumVol::EndSelectAll(), rm_Medium::EndSelectAll(), rm_Slot::EndSelectAll(), rm_MediaPool::EndSelectAll(), rm_DiskSubsys::EndSelectAll(), rm_DriveHost::EndSelectAll(), rm_Drive::EndSelectAll(), rm_Library::EndSelectAll(), fio_DataBase::EndTransaction(), fio_RelFile::GetFirstNewIDX(), fio_JourMgr::GetJourReadHandle(), fio_JourMgr::GetJourWriteHandle(), fio_TransLstMgr::GetTransObj(), fio_RelFile::GetUnusedVectorIDX(), fio_JourMgr::IncTransNumber(), i_FSC_i::IVDFSRecovery(), hsm_JobElemVecMgr::JobToSequence(), fio_DataBase::LockDB(), hsm_FHmigc::Migrate(), rm_ColMediaVol::Next(), rm_MinorCol::Next(), rm_MajorCol::Next(), rm_Partition::Next(), rm_MediumVol::Next(), rm_Medium::Next(), rm_Slot::Next(), rm_MediaPool::Next(), rm_DiskSubsys::Next(), rm_DriveHost::Next(), rm_Drive::Next(), rm_Library::Next(), fio_CirFileTrans::ReadFront(), fio_CirFileTrans::ReadNext(), hsm_FHADPRecall::RecallFilesFromList(), fio_DataBase::RegularSuspend(), cmn_LockIDbyOwn< _T, _size >::ReleaseMutex(), fio_TransLstMgr::ReleaseTransObj(), fio_RelFile::ReleaseVector(), fio_JourMgr::ReleaseWaiters(), fsc_DataLMgr::Remove(), hsm_TimedList::Run(), hsm_FHmigc::Run(), hsm_FHADPRecall::Run(), hsm_FHmigc::SendToPM(), fio_PermDBinfoMgr::SetJourDate(), fio_PermDBinfoMgr::SetLastSyncPosition(), fio_PermDBinfoMgr::SetLastTransaction(), rm_ColMediaVol::StartSelectAll(), rm_MinorCol::StartSelectAll(), rm_MajorCol::StartSelectAll(), rm_Partition::StartSelectAll(), rm_MediumVol::StartSelectAll(), rm_Medium::StartSelectAll(), rm_Slot::StartSelectAll(), rm_MediaPool::StartSelectAll(), rm_DiskSubsys::StartSelectAll(), rm_DriveHost::StartSelectAll(), rm_Drive::StartSelectAll(), rm_Library::StartSelectAll(), fio_DataBase::StartTransaction(), hsm_FHdirty::TaskTime(), hsm_DirWaitList::TaskTime(), hsm_FHrelc::Truncate(), hsm_FHrelc::TruncationCheck(), fio_DataBase::UnlockDB(), fio_CirFileTrans::WriteBack(), fio_RelFile::WriteRec(), and fio_DataBase::~fio_DataBase().

                       {

#ifdef ivd_THREAD_DEBUG_d

    register ivd_ThreadID_t tid = ivd_GETTID();

    if (m_tid == tid) {
        m_tid = 0;
    }
    else {
        log_FUNC_m(Unlock);
        throw ivd_InternalError(ie_MUTEX,
            "Unlock done when not holding mutex. tid = " +
            cmn_Num2Str((UInt32_t)m_tid));
    }
#endif

    int retval(0);
    OMNITHREAD_EXEC_m(Unlock, unlock());
//    OMNITHREAD_EXEC_m(Unlock, retval = unlock());
    if (retval != 0) {
        log_FUNC_m(Unlock);
        register ivd_ThreadID_t tid = ivd_GETTID();
        ostringstream sstr;
        sstr
            << "Possible unlock when mutex not held. "
            << "Unlock returned error number: " << retval
            << " for thread: " << tid;
        throw ivd_InternalError(ie_MUTEX, sstr.str());
    }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 88 of file thread.h.


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