ACE_RWLock_Invariants Class Reference

RWLock Invariants. More...

#include <Token_Invariants.h>

List of all members.

Public Member Functions

 ACE_RWLock_Invariants (void)
 Default construction.

int writer_acquired (void)
int reader_acquired (void)
void releasing (void)
 Updates internal database.

 ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs)
 Copy construction.

void operator= (const ACE_RWLock_Invariants &rhs)
 Copy.

void dump (void) const
 Dump the state of the class.


Private Attributes

int writers_
 Number of owning writers.

int readers_
 Number of owning readers.


Detailed Description

RWLock Invariants.

Preserve the following invariants:

  1. Only one writer at a time.
  2. If there is an owning writer, there are no owning readers.

Definition at line 82 of file Token_Invariants.h.


Constructor & Destructor Documentation

ACE_RWLock_Invariants::ACE_RWLock_Invariants void   ) 
 

Default construction.

Definition at line 281 of file Token_Invariants.cpp.

00282 : writers_ (0),
00283   readers_ (0)
00284 {
00285 }

ACE_RWLock_Invariants::ACE_RWLock_Invariants const ACE_RWLock_Invariants rhs  ) 
 

Copy construction.

Definition at line 328 of file Token_Invariants.cpp.

00329 : writers_ (rhs.writers_),
00330   readers_ (rhs.readers_)
00331 {
00332 }


Member Function Documentation

void ACE_RWLock_Invariants::dump void   )  const
 

Dump the state of the class.

Definition at line 342 of file Token_Invariants.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.

00343 {
00344 #if defined (ACE_HAS_DUMP)
00345   ACE_TRACE ("ACE_RWLock_Invariants::dump");
00346   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00347   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("writers_ = %d readers_ = %d\n"),
00348               writers_, readers_));
00349   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00350 #endif /* ACE_HAS_DUMP */
00351 }

void ACE_RWLock_Invariants::operator= const ACE_RWLock_Invariants rhs  ) 
 

Copy.

Definition at line 335 of file Token_Invariants.cpp.

References readers_, and writers_.

00336 {
00337   writers_ = rhs.writers_;
00338   readers_ = rhs.readers_;
00339 }

int ACE_RWLock_Invariants::reader_acquired void   ) 
 

Returns 1 on success, 0 when an invariant has been violated and -1 on error.

Definition at line 305 of file Token_Invariants.cpp.

Referenced by ACE_Token_Invariant_Manager::reader_acquired().

00306 {
00307   if (writers_ > 0)
00308     {
00309       writers_ = readers_ = 42;
00310       return 0;
00311     }
00312   else
00313     {
00314       ++readers_;
00315       return 1;
00316     }
00317 }

void ACE_RWLock_Invariants::releasing void   ) 
 

Updates internal database.

Definition at line 320 of file Token_Invariants.cpp.

Referenced by ACE_Token_Invariant_Manager::rwlock_releasing().

00321 {
00322   if (writers_ == 1)
00323     writers_ = 0;
00324   else if (readers_ > 0)
00325     --readers_;
00326 }

int ACE_RWLock_Invariants::writer_acquired void   ) 
 

Returns 1 on success, 0 when an invariant has been violated and -1 on error.

Definition at line 288 of file Token_Invariants.cpp.

Referenced by ACE_Token_Invariant_Manager::writer_acquired().

00289 {
00290   if (readers_ > 0)
00291     {
00292       writers_ = readers_ = 42;
00293       return 0;
00294     }
00295   else if (++writers_ > 1)
00296     {
00297       writers_ = readers_ = 42;
00298       return 0;
00299     }
00300   else
00301     return 1;
00302 }


Member Data Documentation

int ACE_RWLock_Invariants::readers_ [private]
 

Number of owning readers.

Definition at line 115 of file Token_Invariants.h.

Referenced by operator=().

int ACE_RWLock_Invariants::writers_ [private]
 

Number of owning writers.

Definition at line 112 of file Token_Invariants.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:28:25 2006 for ACE by doxygen 1.3.6