ldas-tools-al 2.6.7
Loading...
Searching...
No Matches
anonymous_namespace{MemChecker.cc}::MutexLock Class Reference

Descibes an object which release a mutex lock. More...

#include <mutexlock.hh>

Collaboration diagram for anonymous_namespace{MemChecker.cc}::MutexLock:

Classes

class  baton_type
class  BusyError
 Alias for the system specific mutex type. More...

Public Member Functions

 MutexLock (baton_type Baton, const char *const File, const unsigned int Line)
 Constructor.
 MutexLock (baton_type Baton, const char *const File, const unsigned int Line)
 Constructor.
 ~MutexLock ()
 Destructor.
 ~MutexLock ()
 Destructor.
void Release (const char *const File, const unsigned int Line)
 Release the lock before object is destructed.
void Release (const char *const File, const unsigned int Line)
 Release the lock before object is destructed.

Static Public Member Functions

static baton_type Baton ()
 Create a baton that is appropriate for use with this class.
static baton_type Baton ()
 Create a baton that is appropriate for use with this class.
static void ThreadCancel (void *VLock, const char *File=__FILE__, const unsigned int Line=__LINE__)
 Handler for thead cancelation.
static void ThreadCancel (void *VLock, const char *File=__FILE__, const unsigned int Line=__LINE__)
 Handler for thead cancelation.

Private Member Functions

 MutexLock ()
 Default Constructor.
 MutexLock (const MutexLock &)
 Copy Constructor.
 MutexLock ()
 Default Constructor.
 MutexLock (const MutexLock &)
 Copy Constructor.
const MutexLockoperator= (const MutexLock &)
 Assigment operator.
const MutexLockoperator= (const MutexLock &)
 Assigment operator.

Private Attributes

baton_type baton
 Object to prevent multiple access to critical sections of code.
bool m_logging
 Keeps track of logging state.

Detailed Description

Descibes an object which release a mutex lock.

This class ensures that the given mutex is unlocked whenever an exception is thrown but not caught in a locked section.

It should be used like this:

{
MutexLock lock(baton); // mutex is now locked
do whatever...
...
} // MutexLock has been destructed so mutex is now unlocked
baton_type baton
Object to prevent multiple access to critical sections of code.
Definition mutexlock.hh:168
MutexLock(baton_type Baton, const char *const File, const unsigned int Line)
Constructor.
Definition mutexlock.cc:147

Creating two MutexLock objects with the same mutex in the same scope will cause a deadlock.

Constructor & Destructor Documentation

◆ MutexLock() [1/6]

LDASTools::AL::MutexLock::MutexLock ( baton_type Baton,
const char *const File,
const unsigned int Line )

Constructor.

Parameters
BatonThe object to provide lock syncronization.
FileThe from where the request was made.
LineThe line number from where the request was made.

This contructor creates an object to ensure the releasing of the exclusive lock once the object goes out of scope. The lock held by the object can be released early by calling the Release method.

autotoc_md0

See also
Release

◆ MutexLock() [2/6]

LDASTools::AL::MutexLock::MutexLock ( )
private

Default Constructor.

Default constructor is private to prevent copying of classes internal data.

◆ MutexLock() [3/6]

LDASTools::AL::MutexLock::MutexLock ( const MutexLock & )
private

Copy Constructor.

Copy constructor is private to prevent copying of classes internal data.

◆ MutexLock() [4/6]

LDASTools::AL::MutexLock::MutexLock ( baton_type Baton,
const char *const File,
const unsigned int Line )

Constructor.

Parameters
BatonThe object to provide lock syncronization.
FileThe from where the request was made.
LineThe line number from where the request was made.

◆ MutexLock() [5/6]

LDASTools::AL::MutexLock::MutexLock ( )
private

Default Constructor.

Default constructor is private to prevent copying of classes internal data.

◆ MutexLock() [6/6]

LDASTools::AL::MutexLock::MutexLock ( const MutexLock & )
private

Copy Constructor.

Copy constructor is private to prevent copying of classes internal data.

◆ ~MutexLock() [1/2]

LDASTools::AL::MutexLock::~MutexLock ( )

Destructor.

◆ ~MutexLock() [2/2]

LDASTools::AL::MutexLock::~MutexLock ( )

Destructor.

Member Function Documentation

◆ Baton() [1/2]

MutexLock::baton_type LDASTools::AL::MutexLock::Baton ( )
static

Create a baton that is appropriate for use with this class.

◆ Baton() [2/2]

baton_type LDASTools::AL::MutexLock::Baton ( )
static

Create a baton that is appropriate for use with this class.

◆ operator=() [1/2]

const MutexLock & LDASTools::AL::MutexLock::operator= ( const MutexLock & )
private

Assigment operator.

Assignment operator is privat to prevent copying of classes internal data

◆ operator=() [2/2]

const MutexLock & LDASTools::AL::MutexLock::operator= ( const MutexLock & )
private

Assigment operator.

Assignment operator is privat to prevent copying of classes internal data

◆ Release() [1/2]

void LDASTools::AL::MutexLock::Release ( const char *const File,
const unsigned int Line )

Release the lock before object is destructed.

◆ Release() [2/2]

void LDASTools::AL::MutexLock::Release ( const char *const File,
const unsigned int Line )

Release the lock before object is destructed.

◆ ThreadCancel() [1/2]

void LDASTools::AL::MutexLock::ThreadCancel ( void * VLock,
const char * File = __FILE__,
const unsigned int Line = __LINE__ )
static

Handler for thead cancelation.

Parameters
[in]VLockThe VLock is a pointer to a ReadWriteLock object that holds a lock.
[in]FileThe file where the request was made.
[in]LineThe line number from where the request was made.

This routine is used when a thread is canceled and the lock needs to be release. It is currently only written to support pthread_cancel_push().

◆ ThreadCancel() [2/2]

void LDASTools::AL::MutexLock::ThreadCancel ( void * VLock,
const char * File = __FILE__,
const unsigned int Line = __LINE__ )
static

Handler for thead cancelation.

Parameters
[in]VLockThe VLock is a pointer to a ReadWriteLock object that holds a lock.
[in]FileThe file where the request was made.
[in]LineThe line number from where the request was made.

Member Data Documentation

◆ baton

baton_type LDASTools::AL::MutexLock::baton
private

Object to prevent multiple access to critical sections of code.

◆ m_logging

bool LDASTools::AL::MutexLock::m_logging
private

Keeps track of logging state.


The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/ldas-tools-al-2.6.7-build/ldas-tools-al-2.6.7/build/include/ldastoolsal/mutexlock.hh
  • /home/abuild/rpmbuild/BUILD/ldas-tools-al-2.6.7-build/ldas-tools-al-2.6.7/src/mutexlock.hh
  • /home/abuild/rpmbuild/BUILD/ldas-tools-al-2.6.7-build/ldas-tools-al-2.6.7/src/mutexlock.cc