This data structure is meant to be used within a method or function... It performs automatic acquisition and release of a parameterized synchronization object ACE_LOCK.
More...
#include <Guard_T.h>
|
| | ACE_Guard (ACE_LOCK *lock) |
| | Helper, meant for subclass only.
|
|
| ACE_LOCK * | lock_ |
| | Pointer to the ACE_LOCK we're guarding.
|
| int | owner_ |
| | Keeps track of whether we acquired the lock or failed.
|
template<class ACE_LOCK>
class ACE_Guard< ACE_LOCK >
This data structure is meant to be used within a method or function... It performs automatic acquisition and release of a parameterized synchronization object ACE_LOCK.
The ACE_LOCK class given as an actual parameter must provide, at the very least the acquire(), tryacquire(), release(), and remove() methods.
- Warning
- A successfully constructed ACE_Guard does NOT mean that the lock was acquired! It is the caller's responsibility, after constructing an ACE_Guard, to check whether the lock was successfully acquired. Code like this is dangerous: { ACE_Guard<ACE_Lock> g(lock); ... perform critical operation requiring lock to be held ... } Instead, one must do something like this: { ACE_Guard<ACE_Lock> g(lock); if (! g.locked()) { ... handle error ... } else { ... perform critical operation requiring lock to be held ... } } The ACE_GUARD_RETURN() and ACE_GUARD_REACTION() macros are designed to to help with this.
◆ ACE_Guard() [1/5]
template<class ACE_LOCK>
| ACE_Guard< ACE_LOCK >::ACE_Guard |
( |
ACE_LOCK & | l | ) |
|
|
inline |
◆ ACE_Guard() [2/5]
template<class ACE_LOCK>
| ACE_Guard< ACE_LOCK >::ACE_Guard |
( |
ACE_LOCK & | l, |
|
|
bool | block ) |
|
inline |
Implicitly and automatically acquire (or try to acquire) the lock. If block is non-0 then acquire() the ACE_LOCK, else tryacquire() it.
◆ ACE_Guard() [3/5]
template<class ACE_LOCK>
| ACE_Guard< ACE_LOCK >::ACE_Guard |
( |
ACE_LOCK & | l, |
|
|
bool | block, |
|
|
int | become_owner ) |
|
inline |
Initialize the guard without implicitly acquiring the lock. The become_owner parameter indicates whether the guard should release the lock implicitly on destruction. The block parameter is ignored and is used here to disambiguate with the preceding constructor.
◆ ~ACE_Guard()
Implicitly release the lock.
◆ ACE_Guard() [4/5]
template<class ACE_LOCK>
| ACE_Guard< ACE_LOCK >::ACE_Guard |
( |
ACE_LOCK * | lock | ) |
|
|
inlineprotected |
Helper, meant for subclass only.
◆ ACE_Guard() [5/5]
◆ acquire()
Explicitly acquire the lock.
◆ disown()
Relinquish ownership of the lock so that it is not released implicitly in the destructor.
◆ dump()
Dump the state of an object.
◆ locked()
true if locked, false if couldn't acquire the lock (errno will contain the reason for this).
◆ operator=()
◆ release()
Explicitly release the lock, but only if it is held!
◆ remove()
Explicitly remove the lock.
◆ tryacquire()
Conditionally acquire the lock (i.e., won't block).
◆ lock_
Pointer to the ACE_LOCK we're guarding.
◆ owner_
Keeps track of whether we acquired the lock or failed.
The documentation for this class was generated from the following files: