Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

VersionRWLock Class Reference

#include <VersionRWLock.h>

List of all members.


Detailed Description

The VersionRWLoc class implements a read write Lock that will not block the writers.

The writers can always read, but the readers can only read if no writer is writing.

When the reader is reading, the writer can write at the same time. But the writer always update the version after before it write the data. Thus the reaser can check the version before and after read action to check whether the data has been updated.


Public Member Functions

 VersionRWLock ()
 Constructor the lock.
int32 readVersion ()
 Gets read permit and returns the current version.
bool verifyVersion (int32 version)
 verify whether the given version and the current version is the same.
void writeLock ()
 Write lock the structure (no readers are alowed) and update the version.
void writeUnLock ()
 Write unlock the structure.


Constructor & Destructor Documentation

VersionRWLock::VersionRWLock  ) 
 

Constructor the lock.

Defines a read write Lock that will not block the writers. The writers can always read, but the readers can only read if no writer is writing.

While the reader is reading, the writer can write at the same time, thus the user must check whether the version is valid after reading.


Member Function Documentation

int32 VersionRWLock::readVersion  ) 
 

Gets read permit and returns the current version.

bool VersionRWLock::verifyVersion int32  version  ) 
 

verify whether the given version and the current version is the same.

Returns true if so.

Parameters:
version the version to be verified

void VersionRWLock::writeLock  ) 
 

Write lock the structure (no readers are alowed) and update the version.

void VersionRWLock::writeUnLock  ) 
 

Write unlock the structure.

If there are no writers, then wakeup the waiting readers


The documentation for this class was generated from the following files:
Generated on Fri Nov 12 15:15:24 2004 for Borealis by doxygen 1.3.8