NCBI C++ ToolKit
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
CSeqDBLockHold Class Reference

Search Toolkit Book for CSeqDBLockHold

CSeqDBLockHold. More...

#include <objtools/blast/seqdb_reader/impl/seqdbatlas.hpp>

+ Collaboration diagram for CSeqDBLockHold:

Public Member Functions

 CSeqDBLockHold (class CSeqDBAtlas &atlas)
 Constructor. More...
 
 ~CSeqDBLockHold ()
 Destructor. More...
 

Private Member Functions

 CSeqDBLockHold (CSeqDBLockHold &oth)
 Private method to prevent copy construction. More...
 
CSeqDBLockHoldoperator= (CSeqDBLockHold &oth)
 

Static Private Member Functions

static int x_GetClassMark ()
 
static string x_GetMarkString ()
 

Private Attributes

int m_ClassMark
 
class CSeqDBAtlasm_Atlas
 This reference allows unlock on exit. More...
 
volatile bool m_Locked
 If this is true, this thread owns the atlas lock. More...
 

Friends

class CSeqDBAtlas
 Only the atlas code is permitted to modify this object - it does so simply by editing the m_Locked member as needed. More...
 

Detailed Description

CSeqDBLockHold.

This class is used to keep track of whether this thread holds the atlas lock. The atlas code will skip subsequent Lock() operations during the same transaction if the lock is already held. This allows code that needs locking to get the lock without worrying about whether the calling function has already done so. The destructor of this object will call Unlock() on the atlas if this thread has it locked.

Definition at line 167 of file seqdbatlas.hpp.

Constructor & Destructor Documentation

◆ CSeqDBLockHold() [1/2]

CSeqDBLockHold::CSeqDBLockHold ( class CSeqDBAtlas atlas)
inline

Constructor.

This object constructs to an unlocked state, which means that the thread owning the stack frame where this object is stored does not hold the atlas lock. This object keeps a reference to the atlas object so that it can release the lock on destruction, making it easier to write exception safe code.

Parameters
atlasA reference to the atlas object.

Definition at line 178 of file seqdbatlas.hpp.

References INIT_CLASS_MARK.

◆ ~CSeqDBLockHold()

CSeqDBLockHold::~CSeqDBLockHold ( )

Destructor.

The class will unlock the atlas's lock on destruction (if it is the owner of that lock).

Definition at line 337 of file seqdbatlas.cpp.

References BREAK_MARKER, CHECK_MARKER, m_Atlas, and CSeqDBAtlas::Unlock().

◆ CSeqDBLockHold() [2/2]

CSeqDBLockHold::CSeqDBLockHold ( CSeqDBLockHold oth)
private

Private method to prevent copy construction.

Member Function Documentation

◆ operator=()

CSeqDBLockHold& CSeqDBLockHold::operator= ( CSeqDBLockHold oth)
private

◆ x_GetClassMark()

static int CSeqDBLockHold::x_GetClassMark ( )
inlinestaticprivate

Definition at line 193 of file seqdbatlas.hpp.

◆ x_GetMarkString()

static string CSeqDBLockHold::x_GetMarkString ( )
inlinestaticprivate

Definition at line 193 of file seqdbatlas.hpp.

Friends And Related Function Documentation

◆ CSeqDBAtlas

friend class CSeqDBAtlas
friend

Only the atlas code is permitted to modify this object - it does so simply by editing the m_Locked member as needed.

Definition at line 201 of file seqdbatlas.hpp.

Member Data Documentation

◆ m_Atlas

class CSeqDBAtlas& CSeqDBLockHold::m_Atlas
private

This reference allows unlock on exit.

Definition at line 204 of file seqdbatlas.hpp.

Referenced by CSeqDBFileMemMap::Clear(), CSeqDBFileMemMap::Init(), ~CSeqDBLockHold(), and CSeqDBMemReg::~CSeqDBMemReg().

◆ m_ClassMark

int CSeqDBLockHold::m_ClassMark
private

Definition at line 193 of file seqdbatlas.hpp.

◆ m_Locked

volatile bool CSeqDBLockHold::m_Locked
private

If this is true, this thread owns the atlas lock.

Definition at line 207 of file seqdbatlas.hpp.

Referenced by CSeqDBAtlas::Lock(), and CSeqDBAtlas::Unlock().


The documentation for this class was generated from the following files:
Modified on Mon Mar 04 05:13:09 2024 by modify_doxy.py rev. 669887