Server
API Reference Guide
Product Documentation:

Visualization Server
Documentation Home
List of all members | Public Member Functions | Friends
IlsRWLock Class Reference

API FOR ADVANCED USERS – A readers/writer lock is used to allow concurrent access to readers and unique access to writers. More...

#include <ilserver/ilthread.h>

Inheritance diagram for IlsRWLock:
IlsMTBase

Public Member Functions

 IlsRWLock (IlsUnsafeMutex *=0)
 Constructor. More...
 
IlsBoolean rdlock ()
 This member function blocks until the thread acquires a read lock. More...
 
IlsBoolean unlock ()
 This member function unlocks the lock that was previously taken by the thread. More...
 
IlsBoolean wrlock ()
 This member function blocks until the thread acquires a write lock. More...
 
- Public Member Functions inherited from IlsMTBase
virtual ~IlsMTBase ()
 This is the public virtual destructor for this class.
 
virtual IlsThreadObjectName getName () const
 This member function returns the name of an object. More...
 

Friends

ostream & operator<< (ostream &, const IlsRWLock &)
 This operator prints the name of the object to the output stream. More...
 

Detailed Description

API FOR ADVANCED USERS – A readers/writer lock is used to allow concurrent access to readers and unique access to writers.

Library: server
and mvcomp

Certain error conditions are detected and flagged, such as an attempt to take a read lock when the thread already has a write lock, and vice versa. In these cases, the lock() member functions return IlsFalse. The scheduling is done so that writers have priority. Hence, if a reader is running, new readers will be allowed just until a writer is blocked.

Once a writer is waiting, all new readers will block until there are no more waiting writers. It is possible to provide the pointer to the mutex to use to protect the readers/writer lock. For details, see IlsCond.

See also
IlsCond, IlsRWLocker, IlsThread, IlsUnsafeMutex.

Constructor & Destructor Documentation

◆ IlsRWLock()

IlsRWLock::IlsRWLock ( IlsUnsafeMutex = 0)

Constructor.

If a mutex is passed to the constructor, then it is the responsibility of the application to lock the mutex before accessing member functions.

Member Function Documentation

◆ rdlock()

IlsBoolean IlsRWLock::rdlock ( )

This member function blocks until the thread acquires a read lock.

It returns IlsFalse if an error occurs or if the thread already has a write lock.

◆ unlock()

IlsBoolean IlsRWLock::unlock ( )

This member function unlocks the lock that was previously taken by the thread.

It returns IlsFalse if an error occurs or if the thread did not have a lock. rdlock(), wrlock() and unlock() can be nested but the other threads are unblocked only when the last unlock() is performed.

◆ wrlock()

IlsBoolean IlsRWLock::wrlock ( )

This member function blocks until the thread acquires a write lock.

It returns IlsFalse if an error occurs or if the thread already has a read lock.

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  ,
const IlsRWLock  
)
friend

This operator prints the name of the object to the output stream.

This uses the method getName() to get the name of the condition variable. If the method getName() returns 0 then it uses a platform dependent value.