Project stdui: "Simple Type Dialog User-Interface"

|
Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

control::cmutex Class Reference

#include <cmutex.hxx>

Inheritance diagram for control::cmutex:

Inheritance graph
[legend]
List of all members.

Public Types

typedef pthread_mutex_t mutex
 to get the pthread_mutex_t* handle.

Public Member Functions

 cmutex ()
virtual ~cmutex ()
virtual bool init ()
 Initialize the mutex structure.
bool lock ()
void unlock ()
bool isenabled ()
 To check if this mutex is well setup.
bool islocked ()
 unusable if a lock request is not required. This is an misthought design - this method will be removed later.
mutexmutexhandle () const

Protected Attributes

mutex_mutex

Private Attributes

bool _init
bool __locked

Detailed Description

Author:
Serge Lussier

Definition at line 30 of file cmutex.hxx.


Member Typedef Documentation

control::cmutex::mutex
 

to get the pthread_mutex_t* handle.

Definition at line 32 of file cmutex.hxx.


Constructor & Destructor Documentation

control::cmutex::cmutex  ) 
 

Definition at line 27 of file cmutex.cc.

00027               :_mutex(0l),
00028  _init(false)
00029  {
00030 }

control::cmutex::~cmutex  )  [virtual]
 

Definition at line 33 of file cmutex.cc.

References _mutex, and unlock().

00034 {
00035    std::cerr << __PRETTY_FUNCTION__ << std::endl << '{' << std::endl << "." << std::endl;
00036 
00037    if( _mutex ){
00038       unlock();
00039       pthread_mutex_destroy(_mutex);
00040       _mutex = 0l;
00041    }
00042 
00043    std::cerr << std::endl << '}' << std::endl;
00044 }

Here is the call graph for this function:


Member Function Documentation

bool control::cmutex::init  )  [virtual]
 

Initialize the mutex structure.

Reimplemented in control::ccontrol.

Definition at line 54 of file cmutex.cc.

References __locked, _init, and _mutex.

00055 {
00056    _mutex= new pthread_mutex_t;
00057    pthread_mutex_init(_mutex, 0l);
00058    _init = true;
00059    __locked = false;
00060    return true;
00061 }

control::cmutex::isenabled  )  [inline]
 

To check if this mutex is well setup.

Definition at line 45 of file cmutex.hxx.

References _init.

00046     {
00047        return _init;
00048     }

control::cmutex::islocked  )  [inline]
 

unusable if a lock request is not required. This is an misthought design - this method will be removed later.

Definition at line 54 of file cmutex.hxx.

References __locked.

00054 { return __locked; }

bool control::cmutex::lock  ) 
 

Definition at line 67 of file cmutex.cc.

References __locked, _init, and _mutex.

Referenced by control::ccontrol::wait().

00068 {
00069    if(!_init) return false;
00070    if(__locked) return false;
00071    pthread_mutex_lock(_mutex);
00072    __locked = true;
00073    return true;
00074 }

mutex* control::cmutex::mutexhandle  )  const [inline]
 

Definition at line 60 of file cmutex.hxx.

References _mutex.

Referenced by control::ccontrol::wait().

00060 { return _mutex; }

void control::cmutex::unlock  ) 
 

Definition at line 80 of file cmutex.cc.

References __locked, _init, and _mutex.

Referenced by control::ccontrol::release(), and ~cmutex().

00081 {
00082    if(!_init) return;
00083    if(!__locked) return ;
00084    pthread_mutex_unlock(_mutex);
00085    __locked = false;
00086 }


Member Data Documentation

bool control::cmutex::__locked [private]
 

Definition at line 66 of file cmutex.hxx.

Referenced by init(), islocked(), lock(), and unlock().

bool control::cmutex::_init [private]
 

Definition at line 65 of file cmutex.hxx.

Referenced by init(), isenabled(), lock(), and unlock().

mutex* control::cmutex::_mutex [protected]
 

Definition at line 62 of file cmutex.hxx.

Referenced by init(), lock(), mutexhandle(), unlock(), and ~cmutex().


The documentation for this class was generated from the following files:
API Documentation Generated by:  doxygen 1.4.0
About the author | Site started with trial version of DreamWeaver MX 2004 | Finalizing with  | Contact | ©2005, Serge Lussier ( Bretzel )