ACE_Write_Guard< ACE_LOCK > Class Template Reference

This class is similar to class ACE_Guard, though it acquires/releases a write lock automatically (naturally, the <ACE_LOCK> it is instantiated with must support the appropriate API). More...

#include <Guard_T.h>

Inheritance diagram for ACE_Write_Guard< ACE_LOCK >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Write_Guard< ACE_LOCK >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Write_Guard (ACE_LOCK &m)
 Implicitly and automatically acquire a write lock.
 ACE_Write_Guard (ACE_LOCK &m, int block)
int acquire_write (void)
 Explicitly acquire the write lock.
int acquire (void)
 Explicitly acquire the write lock.
int tryacquire_write (void)
 Conditionally acquire the write lock (i.e., won't block).
int tryacquire (void)
 Conditionally acquire the write lock (i.e., won't block).
void dump (void) const
 Dump the state of an object.

Detailed Description

template<class ACE_LOCK>
class ACE_Write_Guard< ACE_LOCK >

This class is similar to class ACE_Guard, though it acquires/releases a write lock automatically (naturally, the <ACE_LOCK> it is instantiated with must support the appropriate API).

Definition at line 119 of file Guard_T.h.


Constructor & Destructor Documentation

template<class ACE_LOCK>
ACE_INLINE ACE_Write_Guard< ACE_LOCK >::ACE_Write_Guard ( ACE_LOCK &  m  ) 

Implicitly and automatically acquire a write lock.

Definition at line 87 of file Guard_T.inl.

References ACE_Write_Guard< ACE_LOCK >::acquire_write().

00088   : ACE_Guard<ACE_LOCK> (&m)
00089 {
00090   this->acquire_write ();
00091 }

template<class ACE_LOCK>
ACE_INLINE ACE_Write_Guard< ACE_LOCK >::ACE_Write_Guard ( ACE_LOCK &  m,
int  block 
)

Implicitly and automatically acquire (or try to acquire) a write lock.

Definition at line 118 of file Guard_T.inl.

References ACE_Write_Guard< ACE_LOCK >::acquire_write(), and ACE_Write_Guard< ACE_LOCK >::tryacquire_write().

00120   : ACE_Guard<ACE_LOCK> (&m)
00121 {
00122   if (block)
00123     this->acquire_write ();
00124   else
00125     this->tryacquire_write ();
00126 }


Member Function Documentation

template<class ACE_LOCK>
ACE_INLINE int ACE_Write_Guard< ACE_LOCK >::acquire ( void   ) 

Explicitly acquire the write lock.

Reimplemented from ACE_Guard< ACE_LOCK >.

Definition at line 100 of file Guard_T.inl.

References ACE_Guard< ACE_LOCK >::lock_, and ACE_Guard< ACE_LOCK >::owner_.

00101 {
00102   return this->owner_ = this->lock_->acquire_write ();
00103 }

template<class ACE_LOCK>
ACE_INLINE int ACE_Write_Guard< ACE_LOCK >::acquire_write ( void   ) 

Explicitly acquire the write lock.

Definition at line 94 of file Guard_T.inl.

References ACE_Guard< ACE_LOCK >::lock_, and ACE_Guard< ACE_LOCK >::owner_.

Referenced by ACE_Write_Guard< ACE_LOCK >::ACE_Write_Guard().

00095 {
00096   return this->owner_ = this->lock_->acquire_write ();
00097 }

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

Dump the state of an object.

Reimplemented from ACE_Guard< ACE_LOCK >.

Definition at line 42 of file Guard_T.cpp.

References ACE_Guard< ACE_LOCK >::dump().

00043 {
00044 #if defined (ACE_HAS_DUMP)
00045 // ACE_TRACE ("ACE_Write_Guard<ACE_LOCK>::dump");
00046   ACE_Guard<ACE_LOCK>::dump ();
00047 #endif /* ACE_HAS_DUMP */
00048 }

template<class ACE_LOCK>
ACE_INLINE int ACE_Write_Guard< ACE_LOCK >::tryacquire ( void   ) 

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

Reimplemented from ACE_Guard< ACE_LOCK >.

Definition at line 112 of file Guard_T.inl.

References ACE_Guard< ACE_LOCK >::lock_, and ACE_Guard< ACE_LOCK >::owner_.

00113 {
00114   return this->owner_ = this->lock_->tryacquire_write ();
00115 }

template<class ACE_LOCK>
ACE_INLINE int ACE_Write_Guard< ACE_LOCK >::tryacquire_write ( void   ) 

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

Definition at line 106 of file Guard_T.inl.

References ACE_Guard< ACE_LOCK >::lock_, and ACE_Guard< ACE_LOCK >::owner_.

Referenced by ACE_Write_Guard< ACE_LOCK >::ACE_Write_Guard().

00107 {
00108   return this->owner_ = this->lock_->tryacquire_write ();
00109 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:52 2010 for ACE by  doxygen 1.4.7