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

LOW_thread_rwlock Class Reference

Abstract base class for read-write locks. More...

#include <LOW_thread_rwlock.h>

Inheritance diagram for LOW_thread_rwlock:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 class_DERIVE_FROM_EXCEPTION (thread_rwlock_error, LOW_exception)
 Exception base class for all exceptions thrown by LOW_thread_rwlock.

 class_DERIVE_FROM_EXCEPTION (thread_rwlock_locked, thread_rwlock_error)
 Exception class to indicate a mutex already locked by the calling thread.

 class_DERIVE_FROM_EXCEPTION (thread_rwlock_busy, thread_rwlock_error)
 Exception class to indicate a mutex locked by another thread.

virtual ~LOW_thread_rwlock ()
 Destructor.

virtual void lockRead ()=0
 Obtain a read lock on the rwlock (blocking).

virtual void tryLockRead ()=0
 Obtain a read lock on the rwlock (non-blocking).

virtual void lockWrite ()=0
 Obtain a write lock on the rwlock (blocking).

virtual void tryLockWrite ()=0
 Obtain a write lock on the rwlock (non-blocking).

virtual void unlock ()=0
 Release a lock on the rwlock.


Detailed Description

Abstract base class for read-write locks.

Each instance represents one lock.

Specific platforms dereive their implementation classes from this class.

The instances are created by LOW_thread_Factory, following the factory design pattern.

This class is thread-safe.

See also:
LOW_thread_Factory
Author:
Harald Roelle

Parts of the documentation taken from Linux man pages by Xavier Leroy.

Parts of the documentation taken from IEEE Standard 1003.1-2003.

Definition at line 41 of file LOW_thread_rwlock.h.


Constructor & Destructor Documentation

LOW_thread_rwlock::~LOW_thread_rwlock  )  [virtual]
 

Destructor.

Exceptions:
thread_rwlock_busy The lock is still locked.
thread_rwlock_error Any other error.

Definition at line 27 of file LOW_thread_rwlock.cpp.


Member Function Documentation

LOW_thread_rwlock::class_DERIVE_FROM_EXCEPTION thread_rwlock_busy  ,
thread_rwlock_error 
 

Exception class to indicate a mutex locked by another thread.

LOW_thread_rwlock::class_DERIVE_FROM_EXCEPTION thread_rwlock_locked  ,
thread_rwlock_error 
 

Exception class to indicate a mutex already locked by the calling thread.

LOW_thread_rwlock::class_DERIVE_FROM_EXCEPTION thread_rwlock_error  ,
LOW_exception 
 

Exception base class for all exceptions thrown by LOW_thread_rwlock.

virtual void LOW_thread_rwlock::lockRead  )  [pure virtual]
 

Obtain a read lock on the rwlock (blocking).

The method applies a read lock to the read-write lock. The calling thread acquires the read lock if a writer does not hold the lock and there are no writers blocked on the lock.

A thread may hold multiple concurrent read locks on rwlock (that is, successfully call the lockRead() method n times). If so, the application shall ensure that the thread performs matching unlocks (that is, it calls unlock() method n times).

Exceptions:
thread_rwlock_locked Calling thread already owns rwlock for writing.
thread_rwlock_error Any other error.

Implemented in LOW_thread_rwlock_POSIX.

Referenced by LOW_objectSynchronizer::__synchronizeMethodRead::__synchronizeMethodRead(), LOW_objectSynchronizer::__synchronizeMethodReadWeak::__synchronizeMethodReadWeak(), and LOW_thread_rwlock::rwLockRead::rwLockRead().

virtual void LOW_thread_rwlock::lockWrite  )  [pure virtual]
 

Obtain a write lock on the rwlock (blocking).

The method applies a write lock to the read-write lock. The calling thread acquires the write lock if no other thread (reader or writer) holds the read-write lock rwlock. Otherwise, the thread will block until it can acquire the lock. The calling thread may deadlock if at the time the call is made it holds the read-write lock (whether a read or write lock).

Exceptions:
thread_rwlock_locked Calling thread already owns the read-write lock for writing or reading.
thread_rwlock_error Any other error.

Implemented in LOW_thread_rwlock_POSIX.

Referenced by LOW_objectSynchronizer::__synchronizeMethodWrite::__synchronizeMethodWrite(), LOW_objectSynchronizer::__synchronizeMethodWriteWeak::__synchronizeMethodWriteWeak(), and LOW_thread_rwlock::rwLockWrite::rwLockWrite().

virtual void LOW_thread_rwlock::tryLockRead  )  [pure virtual]
 

Obtain a read lock on the rwlock (non-blocking).

The method applies a read lock as in the lockRead() method, with the exception that the function throws an exception if the equivalent lockRead() call would have blocked the calling thread. The method never blocks; it always either acquires the lock or throws a thread_rwlock_busy exception.

Exceptions:
thread_rwlock_busy The rwlock is already locked for writing by another thread.
thread_rwlock_locked Calling thread already owns rwlock for writing.
thread_rwlock_error Any other error.

Implemented in LOW_thread_rwlock_POSIX.

Referenced by LOW_objectSynchronizer::__synchronizeMethodRead::__synchronizeMethodRead(), and LOW_objectSynchronizer::__synchronizeMethodReadWeak::__synchronizeMethodReadWeak().

virtual void LOW_thread_rwlock::tryLockWrite  )  [pure virtual]
 

Obtain a write lock on the rwlock (non-blocking).

The method applies a write lock like the lockWrite() method, with the exception that the function throws an exception if any thread currently holds the rwlock (for reading or writing).

Exceptions:
thread_rwlock_busy The rwlock is already locked for reading or writing.
thread_rwlock_locked Calling thread already owns the read-write lock for writing or reading.
thread_rwlock_error Any other error.

Implemented in LOW_thread_rwlock_POSIX.

Referenced by LOW_objectSynchronizer::__synchronizeMethodWrite::__synchronizeMethodWrite(), and LOW_objectSynchronizer::__synchronizeMethodWriteWeak::__synchronizeMethodWriteWeak().

virtual void LOW_thread_rwlock::unlock  )  [pure virtual]
 

Release a lock on the rwlock.

The method releasees a lock held on the read-write lock. Results are undefined if the read-write lock rwlock is not held by the calling thread.

If this method is called to release a read lock from the read-write lock object and there are other read locks currently held on this read-write lock object, the read-write lock object remains in the read locked state. If this method releases the last read lock for this read-write lock object, the read-write lock object is put in the unlocked state with no owners.

If this method is called to release a write lock for this read-write lock object, the read-write lock object is put in the unlocked state.

Exceptions:
thread_rwlock_busy calling thread does not hold a lock.
thread_rwlock_error Any other error.

Implemented in LOW_thread_rwlock_POSIX.

Referenced by LOW_objectSynchronizer::__synchronizeMethodRead::~__synchronizeMethodRead(), LOW_objectSynchronizer::__synchronizeMethodReadWeak::~__synchronizeMethodReadWeak(), LOW_objectSynchronizer::__synchronizeMethodWrite::~__synchronizeMethodWrite(), LOW_objectSynchronizer::__synchronizeMethodWriteWeak::~__synchronizeMethodWriteWeak(), LOW_thread_rwlock::rwLockRead::~rwLockRead(), and LOW_thread_rwlock::rwLockWrite::~rwLockWrite().


The documentation for this class was generated from the following files:
Generated on Tue Feb 3 11:31:08 2004 for OneWireLibrary++ by doxygen 1.3.2