sipxportlib  Version 3.3
Public Member Functions | List of all members
OsLock Class Reference

Lock class for mutual exclusion in a critical section. More...

#include <OsLock.h>

Public Member Functions

 OsLock (OsSyncBase &rSemaphore)
 Constructor. More...
 
virtual ~OsLock ()
 Destructor. More...
 

Detailed Description

Lock class for mutual exclusion in a critical section.

This class uses OsSyncBase objects for synchronization. The constructor for the class automatically blocks until the designated semaphore is acquired. Similarly, the destructor automatically releases the lock. The easiest way to use this object as a guard for a critical section is to create the object as a variable on the stack just before the critical section. When the variable goes out of scope, the lock will be automatically released. An example of this form of use is shown below.

   someMethod()
   {
      OsLock lock(myBSemaphore);

      < critical section >
   }

Constructor & Destructor Documentation

OsLock ( OsSyncBase rSemaphore)
inline

Constructor.

virtual ~OsLock ( )
inlinevirtual

Destructor.