ApparatusFramework::Guard Class Reference
[Kernel Services]

#include <KernelServices/common/current/include/Guard.h>

List of all members.

Public Member Functions

 Guard (Mutex &mutex)
 ~Guard ()
void get ()
void put ()

Detailed Description

The class guard implements an automatic lock and unlock mechanism. A mutex must be provided externaly. This mutex is locked during construction and unlocked during destruction of the guard object. Thus we can guarantee that the mutex is unlocked when the guard object goes out of scope.

To protect a method, simply declare a guard object at the beginning of the method. Another client calling the same method creates a new guard object that tries to lock the same (external) mutex. Therefore, the second client gets suspended until the first guard object goes out of scope.

Definition at line 65 of file Guard.h.

Constructor & Destructor Documentation

ApparatusFramework::Guard::Guard ( Mutex mutex  ) 

Constructs a new guard object and locks the mutex.

mutex reference of the mutex to be used for locking.
ApparatusFramework::Guard::~Guard (  ) 

Destroys the object and unlocks the associated mutex.

Member Function Documentation

void ApparatusFramework::Guard::get (  ) 

Get explicitely locks the associated mutex.

void ApparatusFramework::Guard::put (  ) 

Put explicitely unlocks the associated mutex.

© 2004-2010 bbv Software Services AG / Apparatus Services