ACE_Guard< ACE_LOCK > Class Template Reference

This data structure is meant to be used within a method or function... It performs automatic aquisition and release of a parameterized synchronization object ACE_LOCK. More...

#include <Guard_T.h>

Collaboration diagram for ACE_Guard< ACE_LOCK >:

Collaboration graph
[legend]

List of all members.

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.

Protected Member Functions

 ACE_Guard (ACE_LOCK *lock)
 Helper, meant for subclass only.

Protected Attributes

ACE_LOCK * lock_
 Pointer to the ACE_LOCK we're guarding.
int owner_
 Keeps track of whether we acquired the lock or failed.

Private Member Functions

void operator= (const ACE_Guard< ACE_LOCK > &)
 ACE_Guard (const ACE_Guard< ACE_LOCK > &)


Detailed Description

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 aquisition and release of a parameterized synchronization object ACE_LOCK.

Template specialization of ACE_Guard for the ACE_Null_Mutex.

The <ACE_LOCK> class given as an actual parameter must provide at the very least the <acquire>, <tryacquire>, <release>, and <remove> methods.

This specialization is useful since it helps to speedup performance of the "Null_Mutex" considerably.


Constructor & Destructor Documentation

template<class ACE_LOCK>
ACE_Guard< ACE_LOCK >::ACE_Guard ( ACE_LOCK &  l  ) 

template<class ACE_LOCK>
ACE_Guard< ACE_LOCK >::ACE_Guard ( ACE_LOCK &  l,
bool  block 
)

Implicitly and automatically acquire (or try to acquire) the lock. If block is non-0 then <acquire> the <ACE_LOCK>, else <tryacquire> it.

template<class ACE_LOCK>
ACE_Guard< ACE_LOCK >::ACE_Guard ( ACE_LOCK &  l,
bool  block,
int  become_owner 
)

Initialise 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.

template<class ACE_LOCK>
ACE_Guard< ACE_LOCK >::~ACE_Guard ( void   ) 

Implicitly release the lock.

template<class ACE_LOCK>
ACE_Guard< ACE_LOCK >::ACE_Guard ( ACE_LOCK *  lock  )  [inline, protected]

Helper, meant for subclass only.

template<class ACE_LOCK>
ACE_Guard< ACE_LOCK >::ACE_Guard ( const ACE_Guard< ACE_LOCK > &   )  [private]


Member Function Documentation

template<class ACE_LOCK>
int ACE_Guard< ACE_LOCK >::acquire ( void   ) 

Explicitly acquire the lock.

Reimplemented in ACE_Write_Guard< ACE_LOCK >, and ACE_Read_Guard< ACE_LOCK >.

template<class ACE_LOCK>
void ACE_Guard< ACE_LOCK >::disown ( void   ) 

Relinquish ownership of the lock so that it is not released implicitly in the destructor.

template<class ACE_LOCK>
void ACE_Guard< ACE_LOCK >::dump ( void   )  const

Dump the state of an object.

Reimplemented in ACE_Write_Guard< ACE_LOCK >, and ACE_Read_Guard< ACE_LOCK >.

template<class ACE_LOCK>
bool ACE_Guard< ACE_LOCK >::locked ( void   )  const

true if locked, false if couldn't acquire the lock (errno will contain the reason for this).

template<class ACE_LOCK>
void ACE_Guard< ACE_LOCK >::operator= ( const ACE_Guard< ACE_LOCK > &   )  [private]

template<class ACE_LOCK>
int ACE_Guard< ACE_LOCK >::release ( void   ) 

Explicitly release the lock, but only if it is held!

template<class ACE_LOCK>
int ACE_Guard< ACE_LOCK >::remove ( void   ) 

Explicitly remove the lock.

template<class ACE_LOCK>
int ACE_Guard< ACE_LOCK >::tryacquire ( void   ) 

Conditionally acquire the lock (i.e., won't block).

Reimplemented in ACE_Write_Guard< ACE_LOCK >, and ACE_Read_Guard< ACE_LOCK >.


Member Data Documentation

template<class ACE_LOCK>
ACE_LOCK* ACE_Guard< ACE_LOCK >::lock_ [protected]

Pointer to the ACE_LOCK we're guarding.

template<class ACE_LOCK>
int ACE_Guard< ACE_LOCK >::owner_ [protected]

Keeps track of whether we acquired the lock or failed.


The documentation for this class was generated from the following file:

Generated on Mon Jul 13 16:11:43 2009 for ACE by  doxygen 1.5.8