Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ACS::ThreadSyncGuard Class Reference

Class implementing scope locking synchronization pattern. More...

#include <acsThreadBase.h>

List of all members.

Public Member Functions

 ThreadSyncGuard (ACE_Recursive_Thread_Mutex *mutex, bool block=true)
 ~ThreadSyncGuard ()
void acquire ()
void release ()

Public Attributes

ACE_Recursive_Thread_Mutex * mutex_mp
 mutex used by guard

bool acquired_m
 state of mutex


Detailed Description

Class implementing scope locking synchronization pattern.

ThreadSyncGuard implements scope locking synchronization pattern, which is very usefull not to forget to release (or relase can be by-passed by an exception) and so avoiding deadlocks. Mutex is automatically released when out of scope.
ThreadSyncGuard uses recursive thread mutex. An example of usage:

void PowerSupplyImpl::shutdown() { //ThreadSyncGuard guard("gizmo0::propertyVector"); ThreadSyncGuard guard(mutex_m);

// do something

// optional lock release guard.release();

// do something

// optional locking guard.acquire();

// do something

// lock is automatically released when out of scope

}


Constructor & Destructor Documentation

ACS::ThreadSyncGuard::ThreadSyncGuard ACE_Recursive_Thread_Mutex *  mutex,
bool  block = true
 

Constructor. Creates a guard and acquires mutex if is true.

Parameters:
mutex mutex to be used by guard
block if true, lock is acuired, otherwise not

ACS::ThreadSyncGuard::~ThreadSyncGuard  ) 
 

Destructor. Relases mutex if necessary.


Member Function Documentation

void ACS::ThreadSyncGuard::acquire  ) 
 

Blocks the thread until the lock is acquired.

void ACS::ThreadSyncGuard::release  ) 
 

Releases the lock.


Member Data Documentation

bool ACS::ThreadSyncGuard::acquired_m
 

state of mutex

ACE_Recursive_Thread_Mutex* ACS::ThreadSyncGuard::mutex_mp
 

mutex used by guard


The documentation for this class was generated from the following file:
Generated on Sun Oct 29 02:31:31 2006 for ACS C++ API by doxygen 1.3.6