MAK RTIspy API Documentation for HLA 1.3
Public Member Functions | Protected Member Functions | Protected Attributes
DtRdWrLock__rti__ Class Reference

Platform independent read-lock / write-lock. More...

+ Inheritance diagram for DtRdWrLock__rti__:
+ Collaboration diagram for DtRdWrLock__rti__:

List of all members.

Public Member Functions

 DtRdWrLock__rti__ ()
 default constructor
virtual ~DtRdWrLock__rti__ ()
 destructor
virtual void init ()
 initialize the locking mechanism
virtual void destroy ()
 destroy the lock
virtual int wrLock ()
 lock the protected resource for writing. Return 0 if lock acquired.
virtual int rdLock ()
 lock the protected resource for reading. Return 0 if lock acquired.
virtual int wrUnlock ()
 unlock the write-lock on the protected resource.
virtual int rdUnlock ()
 unlock the read-lock on the protected resource.

Protected Member Functions

 DtRdWrLock__rti__ (const DtRdWrLock__rti__ &orig)
 copy constructor
const DtRdWrLock__rti__operator= (const DtRdWrLock__rti__ &orig)
 assignment operator

Protected Attributes

volatile long readers
 The Win32 implementation uses two counters and the Interlocked Variable Access facility to create a lightweight locking mechanism.
volatile long writers
pthread_rwlock_t myPtLock
pthread_rwlock_t * myLock

Detailed Description

Platform independent read-lock / write-lock.

Instances of DtRdWrLock are used to provide a platform independent read-lock / write-lock mechanism for use by threads of the same process. Do not use this class to implement inter-process comm- unication between threads of different processes.


Constructor & Destructor Documentation

default constructor

copy constructor

destructor

References readers, and writers.


Member Function Documentation

void DtRdWrLock__rti__::destroy ( ) [virtual]

destroy the lock

Reimplemented in DtIpcRdWrLock__rti__.

References myLock, readers, and writers.

void DtRdWrLock__rti__::init ( ) [virtual]

initialize the locking mechanism

Reimplemented in DtIpcRdWrLock__rti__.

References myLock, myPtLock, NULL, readers, and writers.

const DtRdWrLock__rti__ & DtRdWrLock__rti__::operator= ( const DtRdWrLock__rti__ orig) [protected]

assignment operator

int DtRdWrLock__rti__::rdLock ( ) [virtual]

lock the protected resource for reading. Return 0 if lock acquired.

References myLock, readers, and writers.

Referenced by DtSmSubscribableMessageQueue__rti__::lockForRead().

int DtRdWrLock__rti__::rdUnlock ( ) [virtual]

unlock the read-lock on the protected resource.

Return 0 if lock released.

References myLock, and readers.

Referenced by DtSmSubscribableMessageQueue__rti__::unlockForRead().

int DtRdWrLock__rti__::wrLock ( ) [virtual]

lock the protected resource for writing. Return 0 if lock acquired.

References myLock, readers, and writers.

Referenced by DtSmSubscribableMessageQueue__rti__::lockForWrite().

int DtRdWrLock__rti__::wrUnlock ( ) [virtual]

unlock the write-lock on the protected resource.

Return 0 if lock released.

References myLock, and writers.

Referenced by DtSmSubscribableMessageQueue__rti__::unlockForWrite().


Member Data Documentation

pthread_rwlock_t* DtRdWrLock__rti__::myLock [protected]
pthread_rwlock_t DtRdWrLock__rti__::myPtLock [protected]

Referenced by init().

volatile long DtRdWrLock__rti__::readers [protected]

The Win32 implementation uses two counters and the Interlocked Variable Access facility to create a lightweight locking mechanism.

("Lightweight" because it doesn't use semaphores, which are slower). However since the counters are limited in scope to the process that creates them (and any threads that inherit from that process) this mechanism cannot be used for inter-process locking, only intra-process thread locking. In order to avoid having two different ctors for Windows and *nix implementations these counters are present in both implementations and initialized in the ctor init-list, however they are unused in *nix builds This implementation is first-come, first-served which favors writers over readers.

Referenced by DtIpcRdWrLock__rti__::destroy(), destroy(), init(), rdLock(), rdUnlock(), wrLock(), DtIpcRdWrLock__rti__::~DtIpcRdWrLock__rti__(), and ~DtRdWrLock__rti__().

volatile long DtRdWrLock__rti__::writers [protected]

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

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)