Public Member Functions | Private Member Functions | Private Attributes

mlock Class Reference
[Threadsafe Collection API]

class that automatically locks and unlocks pthread mutexes To use mlocks in code:

More...

#include <smart_mutex.h>

List of all members.

Public Member Functions

 mlock (smart_mutex &sm)
 constructor that accepts smart_mutex
 mlock (pthread_mutex_t *pm)
 constructor that accepts pthread mutex
 ~mlock (void)
 destructor automatically unlocks

Private Member Functions

 mlock (void)
 mlock (const mlock &)
void lock (pthread_mutex_t *pm)

Private Attributes

pthread_mutex_t * m_pm

Detailed Description

class that automatically locks and unlocks pthread mutexes To use mlocks in code:

Example:

        void threadsafeFunction(void)
        {
                smart_mutex my_mutex;
   
                mlock lock(my_mutex);   // blocks until mutex is acquired
   
                // some stuff that needs to be protected happens here
                ...
   
        }  <--- mutex is unlocked here as mlock destructor is called

Definition at line 97 of file smart_mutex.h.


Constructor & Destructor Documentation

mlock::mlock ( smart_mutex sm  )  [inline]

constructor that accepts smart_mutex

Definition at line 100 of file smart_mutex.h.


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