|
reSIProcate/rutil
9694
|
A semaphore that can be locked by only one thread at a time. More...
#include <Mutex.hxx>


Public Member Functions | |
| Mutex () | |
| virtual | ~Mutex () |
| virtual void | lock () |
| virtual void | unlock () |
Private Member Functions | |
| Mutex (const Mutex &) | |
| Mutex & | operator= (const Mutex &) |
| pthread_mutex_t * | getId () const |
Private Attributes | |
| pthread_mutex_t | mId |
Friends | |
| class | Condition |
A semaphore that can be locked by only one thread at a time.
Used to serialize access to some resource (such as a data member). Here's an example:
void Log::setLevel(Level level) { Lock lock(_mutex); _level = level; }
As indicated in the example, you will probably never use any member function in this class. The 'Lock' class provides this functionality.
| Mutex::Mutex | ( | ) |
Definition at line 22 of file Mutex.cxx.
References mId.
{
#ifndef WIN32
int rc = pthread_mutex_init(&mId,0);
(void)rc;
assert( rc == 0 );
#else
// Note: Windows Critical sections are recursive in nature and perhaps
// this implementation calls for a non-recursive implementation
// (since there also exists a RecursiveMutex class). The effort
// to make this non-recursive just doesn't make sense though. (SLG)
InitializeCriticalSection(&mId);
#endif
}
| Mutex::~Mutex | ( | ) | [virtual] |
| resip::Mutex::Mutex | ( | const Mutex & | ) | [private] |
| pthread_mutex_t * Mutex::getId | ( | ) | const [private] |
Definition at line 81 of file Mutex.cxx.
References mId.
Referenced by resip::Condition::wait().
{
return ( &mId );
}
| void Mutex::lock | ( | ) | [virtual] |
Implements resip::Lockable.
Definition at line 52 of file Mutex.cxx.
References mId.
Referenced by resip::Condition::wait().
| void Mutex::unlock | ( | ) | [virtual] |
Implements resip::Lockable.
Definition at line 66 of file Mutex.cxx.
References mId.
Referenced by resip::Condition::wait().
pthread_mutex_t resip::Mutex::mId [mutable, private] |
1.7.5.1