In file thread/gmutex.hh:

class recursivemutex : public mutex

Class to store a recuresive mutex.

Inheritance:


Public Methods

recursivemutex ()
Default constructor.
recursivemutex (const recursivemutex&)
Copy constructor.
recursivemutex& operator= (const recursivemutex&)
Assignment operator.
virtual void lock ()
Mutex lock function.
virtual void unlock ()
Mutex unlock function.
virtual bool trylock (locktype lck = rdlock)
Mutex trylock function.

Inherited from mutex:

Public Methods

virtual void readlock()
virtual void writelock()

Inherited from abstractsemaphore:

Public Fields

rdlock
wrlock

Public Methods

virtual bool trylock_timed(int timeout, locktype lck = rdlock)

Public

typedef enum locktype

Documentation

This class is used as a wrapper around a system defined mutex. A recursive mutex is similar to a normal mutex object, but it allows a single task/thread to take a mutex multiple times. This is useful for a set of routines/methods that must call each other but that also require mutually exclusive access to a resource. The recursive mutex keeps track which task/thraad currently owns the mutex and also keeps a reference count on how often it was locked. The system mutex will only be released after the last unlock call. Under Unix this mutex is less effcient than the normal mutex, but sometimes convinient. Under VxWorks this is the default behaviour.

recursivemutex()
Constructs a recuresive mutex object and creates a new mutex.
Returns:
void

recursivemutex(const recursivemutex&)
Constructs a recuresive mutex object by creating a new mutex with reference count zero, rather than copying it.
Returns:
void
Parameters:
another - recursive mutex

recursivemutex& operator= (const recursivemutex&)
Overrides the default assignment behaviour. Does nothing.
Returns:
refrence to object
Parameters:
recursivemutex - copy argument

virtual void lock()
Locks the mutex. If the mutex is alreday taken it checks if the current thread is the same as the one which took the mutex originally. If no, it waits until the mutex becomes free. If yes, it increases the reference count and returns.
Returns:
void

virtual void unlock()
Unlocks the mutex. The mutex becomes free.
Returns:
void

virtual bool trylock(locktype lck = rdlock)
Trys to lock the mutex. If the mutex is alreday taken it checks if current thread is the same as the one which locked the mutex originally. If no, it returns false. If yes, it increases the reference count and returns true.

Returns:
true if locked, false otherwise
Parameters:
writeaccess - ignored


This class has no child classes.
Author:
DS, November 98
See Also:
Recursive mutex objects

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++