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

LOW_thread_rwlock_POSIX Class Reference

Platform specific LOW_thread_rwlock for POSIX platforms. More...

#include <LOW_thread_rwlock_POSIX.h>

Inheritance diagram for LOW_thread_rwlock_POSIX:

Inheritance graph
[legend]
Collaboration diagram for LOW_thread_rwlock_POSIX:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~LOW_thread_rwlock_POSIX ()
 Destructor.

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

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

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

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

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

 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.


Protected Member Functions

 LOW_thread_rwlock_POSIX ()
 Constructor.


Private Attributes

pthread_rwlock_t theRwlock
 The rwlock itself.


Friends

class LOW_thread_Factory
 To allow construction.


Detailed Description

Platform specific LOW_thread_rwlock for POSIX platforms.

This class is thread-safe.

See also:
LOW_thread_rwlock

IEEE Standard 1003.1-2003 (http://www.opengroup.org/onlinepubs/007904975/toc.htm)

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 40 of file LOW_thread_rwlock_POSIX.h.


Constructor & Destructor Documentation

LOW_thread_rwlock_POSIX::~LOW_thread_rwlock_POSIX  )  [virtual]
 

Destructor.

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

Definition at line 42 of file LOW_thread_rwlock_POSIX.cpp.

References LOW_helper_msglog::printPerror(), and theRwlock.

LOW_thread_rwlock_POSIX::LOW_thread_rwlock_POSIX  )  [protected]
 

Constructor.

Not publicly constructable. Use LOW_thread_Factory.

Exceptions:
thread_rwlock_error Any error.

Definition at line 35 of file LOW_thread_rwlock_POSIX.cpp.

References theRwlock.


Member Function Documentation

LOW_thread_rwlock::class_DERIVE_FROM_EXCEPTION thread_rwlock_busy  ,
thread_rwlock_error 
[inherited]
 

Exception class to indicate a mutex locked by another thread.

LOW_thread_rwlock::class_DERIVE_FROM_EXCEPTION thread_rwlock_locked  ,
thread_rwlock_error 
[inherited]
 

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

LOW_thread_rwlock::class_DERIVE_FROM_EXCEPTION thread_rwlock_error  ,
LOW_exception 
[inherited]
 

Exception base class for all exceptions thrown by LOW_thread_rwlock.

void LOW_thread_rwlock_POSIX::lockRead  )  [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.

Implements LOW_thread_rwlock.

Definition at line 57 of file LOW_thread_rwlock_POSIX.cpp.

References theRwlock.

void LOW_thread_rwlock_POSIX::lockWrite  )  [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.

Implements LOW_thread_rwlock.

Definition at line 81 of file LOW_thread_rwlock_POSIX.cpp.

References theRwlock.

void LOW_thread_rwlock_POSIX::tryLockRead  )  [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.

Implements LOW_thread_rwlock.

Definition at line 68 of file LOW_thread_rwlock_POSIX.cpp.

References theRwlock.

void LOW_thread_rwlock_POSIX::tryLockWrite  )  [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.

Implements LOW_thread_rwlock.

Definition at line 92 of file LOW_thread_rwlock_POSIX.cpp.

References theRwlock.

void LOW_thread_rwlock_POSIX::unlock  )  [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.

Implements LOW_thread_rwlock.

Definition at line 105 of file LOW_thread_rwlock_POSIX.cpp.

References theRwlock.


Friends And Related Function Documentation

friend class LOW_thread_Factory [friend]
 

To allow construction.

Definition at line 148 of file LOW_thread_rwlock_POSIX.h.


Member Data Documentation

pthread_rwlock_t LOW_thread_rwlock_POSIX::theRwlock [private]
 

The rwlock itself.

Definition at line 172 of file LOW_thread_rwlock_POSIX.h.

Referenced by lockRead(), lockWrite(), LOW_thread_rwlock_POSIX(), tryLockRead(), tryLockWrite(), unlock(), and ~LOW_thread_rwlock_POSIX().


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