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

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

#include <OsLock.h>

Public Types

enum  TakeStateEnum { Unknown, PreAcquire, PostAcquire, PostRelease }
 
typedef enum OsLock::TakeStateEnum OsLockTakeState
 

Public Member Functions

 OsLock (OsSyncBase &rSemaphore, void(*lockStateCallback)(OsLockTakeState state, void *data)=NULL, void *callbackData=NULL)
 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 >
   }

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
Unknown 
PreAcquire 
PostAcquire 
PostRelease 

Constructor & Destructor Documentation

OsLock ( OsSyncBase rSemaphore,
void(*)(OsLockTakeState state, void *data)  lockStateCallback = NULL,
void *  callbackData = NULL 
)
inline

Constructor.

virtual ~OsLock ( )
inlinevirtual

Destructor.