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...
Public Member Functions |
| ACE_Guard (ACE_LOCK &l) |
| ACE_Guard (ACE_LOCK &l, bool block) |
| ACE_Guard (ACE_LOCK &l, bool block, int become_owner) |
| ~ACE_Guard (void) |
| Implicitly release the lock.
|
int | acquire (void) |
| Explicitly acquire the lock.
|
int | tryacquire (void) |
| Conditionally acquire the lock (i.e., won't block).
|
int | release (void) |
| Explicitly release the lock, but only if it is held!
|
void | disown (void) |
bool | locked (void) const |
int | remove (void) |
| Explicitly remove the lock.
|
void | dump (void) const |
| Dump the state of an object.
|
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.