Public Member Functions
|Guard (Mutex &mutex)|
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.
Constructs a new guard object and locks the mutex.
|mutex||reference of the mutex to be used for locking.|
Destroys the object and unlocks the associated mutex.
Get explicitely locks the associated mutex.
Put explicitely unlocks the associated mutex.
© 2004-2010 bbv Software Services AG / Apparatus Services