Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_RWLock_Invariants Class Reference

RWLock Invariants. More...

#include <Token_Invariants.h>

List of all members.

Public Methods

 ACE_RWLock_Invariants (void)
 Default construction. More...

int writer_acquired (void)
 Returns 1 on success, 0 when an invariant has been violated and -1 on error. More...

int reader_acquired (void)
 Returns 1 on success, 0 when an invariant has been violated and -1 on error. More...

void releasing (void)
 Updates internal database. More...

 ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs)
 Copy construction. More...

void operator= (const ACE_RWLock_Invariants &rhs)
 Copy. More...

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


Private Attributes

int writers_
 Number of owning writers. More...

int readers_
 Number of owning readers. More...


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 79 of file Token_Invariants.h.


Constructor & Destructor Documentation

ACE_RWLock_Invariants::ACE_RWLock_Invariants void   
 

Default construction.

Definition at line 274 of file Token_Invariants.cpp.

00275 : writers_ (0),
00276   readers_ (0)
00277 {
00278 }

ACE_RWLock_Invariants::ACE_RWLock_Invariants const ACE_RWLock_Invariants &    rhs
 

Copy construction.

Definition at line 321 of file Token_Invariants.cpp.

00322 : writers_ (rhs.writers_),
00323   readers_ (rhs.readers_)
00324 {
00325 }


Member Function Documentation

void ACE_RWLock_Invariants::dump void    const
 

Dump the state of the class.

Definition at line 335 of file Token_Invariants.cpp.

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

00336 {
00337   ACE_TRACE ("ACE_RWLock_Invariants::dump");
00338   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00339   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("writers_ = %d\n"),
00340               "readers_ = %d\n",
00341               writers_, readers_));
00342   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00343 }

void ACE_RWLock_Invariants::operator= const ACE_RWLock_Invariants &    rhs
 

Copy.

Definition at line 328 of file Token_Invariants.cpp.

References readers_, and writers_.

00329 {
00330   writers_ = rhs.writers_;
00331   readers_ = rhs.readers_;
00332 }

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 298 of file Token_Invariants.cpp.

References readers_, and writers_.

Referenced by ACE_Token_Invariant_Manager::reader_acquired.

00299 {
00300   if (writers_ > 0)
00301     {
00302       writers_ = readers_ = 42;
00303       return 0;
00304     }
00305   else
00306     {
00307       ++readers_;
00308       return 1;
00309     }
00310 }

void ACE_RWLock_Invariants::releasing void   
 

Updates internal database.

Definition at line 313 of file Token_Invariants.cpp.

References readers_, and writers_.

Referenced by ACE_Token_Invariant_Manager::rwlock_releasing.

00314 {
00315   if (writers_ == 1)
00316     writers_ = 0;
00317   else if (readers_ > 0)
00318     --readers_;
00319 }

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 281 of file Token_Invariants.cpp.

References readers_, and writers_.

Referenced by ACE_Token_Invariant_Manager::writer_acquired.

00282 {
00283   if (readers_ > 0)
00284     {
00285       writers_ = readers_ = 42;
00286       return 0;
00287     }
00288   else if (++writers_ > 1)
00289     {
00290       writers_ = readers_ = 42;
00291       return 0;
00292     }
00293   else
00294     return 1;
00295 }


Member Data Documentation

int ACE_RWLock_Invariants::readers_ [private]
 

Number of owning readers.

Definition at line 112 of file Token_Invariants.h.

Referenced by dump, operator=, reader_acquired, releasing, and writer_acquired.

int ACE_RWLock_Invariants::writers_ [private]
 

Number of owning writers.

Definition at line 109 of file Token_Invariants.h.

Referenced by dump, operator=, reader_acquired, releasing, and writer_acquired.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:55:30 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002