library of assembled shared sources

http://lass.cocamware.com

lass::util::RWLock Class Reference
[Threading]

Lean and mean synchronisation object, without OS support. More...

#include <rw_lock.h>

Inheritance diagram for lass::util::RWLock:

Inheritance graph
[legend]
Collaboration diagram for lass::util::RWLock:

Collaboration graph
[legend]

Public Member Functions

 RWLock (util::CallTraits< size_t >::TParam iMaxReaders)
 ~RWLock ()
void lockr ()
void lockw ()
void unlockr ()
void unlockw ()
const LockResult tryLockr ()
const LockResult tryLockw ()

Private Member Functions

void swap (NonCopyable &)

Private Attributes

size_t maxReaders_
 the maximum of simultaneous readers allowed
int spinLock_
int writersTrying_
 the number of writers trying to enter

Detailed Description

Lean and mean synchronisation object, without OS support.

See also:
RWLocker
Author:
Tom De Muer
Date:
2006
This lock is built upon atomic operations that are programmed in assembly. It makes a difference between reading and writing. A maximum number of readers is allowed while only 1 writer is allowed. The writer will only enter if there are no readers are reading at the same moment. This RWLock is a blocking and spinning synchronization object. Priority is given over writers, as soon as a writer is trying to enter, only one subsequent reader will in worst case be able to enter.

Definition at line 73 of file rw_lock.h.


Constructor & Destructor Documentation

lass::util::RWLock::RWLock ( util::CallTraits< size_t >::TParam  iMaxReaders  ) 

Definition at line 95 of file rw_lock.h.

References maxReaders_, spinLock_, and writersTrying_.

lass::util::RWLock::~RWLock (  ) 

Definition at line 102 of file rw_lock.h.

References LASS_ENFORCE, maxReaders_, and spinLock_.


Member Function Documentation

void lass::util::RWLock::lockr (  ) 

Definition at line 107 of file rw_lock.h.

References lass::util::atomicCompareAndSwap(), LASS_ASSERT, spinLock_, and writersTrying_.

void lass::util::RWLock::lockw (  ) 

Definition at line 119 of file rw_lock.h.

References lass::util::atomicIncrement(), maxReaders_, spinLock_, and writersTrying_.

void lass::util::RWLock::unlockr (  ) 

Definition at line 136 of file rw_lock.h.

References lass::util::atomicIncrement(), LASS_ASSERT, maxReaders_, and spinLock_.

void lass::util::RWLock::unlockw (  ) 

const LockResult lass::util::RWLock::tryLockr (  ) 

const LockResult lass::util::RWLock::tryLockw (  ) 

void lass::util::NonCopyable::swap ( NonCopyable  )  [inline, protected, inherited]

Definition at line 60 of file non_copyable.h.

Referenced by lass::io::Image::readLine().


Field Documentation

the maximum of simultaneous readers allowed

Definition at line 89 of file rw_lock.h.

Referenced by lockw(), RWLock(), tryLockw(), unlockr(), unlockw(), and ~RWLock().

Definition at line 90 of file rw_lock.h.

Referenced by lockr(), lockw(), RWLock(), tryLockr(), tryLockw(), unlockr(), unlockw(), and ~RWLock().

the number of writers trying to enter

Definition at line 91 of file rw_lock.h.

Referenced by lockr(), lockw(), RWLock(), tryLockw(), and unlockw().


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

Generated on Mon Nov 10 14:22:17 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo