In file thread/gmutex.hh:

class mutex : public abstractsemaphore

Class to store a mutex.

Inheritance:


Public Methods

mutex ()
Default constructor.
virtual ~mutex ()
Default destructor.
mutex (const mutex&)
Copy constructor.
mutex& operator= (const mutex&)
Assignment operator.
virtual void lock ()
Mutex lock function.
virtual void readlock ()
Mutex readlock function.
virtual void writelock ()
Mutex writelock function.
virtual void unlock ()
Mutex unlock function.
virtual bool trylock (locktype lck = rdlock)
Mutex trylock function.

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. During construction the mutex is created and during desctruction it is automatically destroyed. A mutex object describes a unique mutex which can not be copied. When passing a mutex object to a function it has to be passed by reference or by pointer (never by value). There are methods to lock, unlock and trylock the mutex. On Unix the object uses the POSIX standard, whereas under VxWorks it uses the native mutex Lock and unlock methods must always be used in pairs within the same context.

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

virtual ~mutex()
Destructs a mutex object and destroyes the mutex.
Returns:
void

mutex(const mutex&)
Constructs a mutex object, overwritting the default copy constructor by creating a new mutex.
Returns:
void

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

virtual void lock()
Locks the mutex. If the mutex is not available waits until it becomes free.
Returns:
void

virtual void readlock()
Locks the mutex for read, same as lock().
Returns:
void

virtual void writelock()
Locks the mutex for write, same as lock().
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 free, it gets locked and the method returns true. If the mutex is already taken, the method returns false.
Returns:
true if locked, false otherwise
Parameters:
writeaccess - ignored


Direct child classes:
static_ref_counter
recursivemutex
Author:
DS, November 98
See Also:
Mutex objects

alphabetic index hierarchy of classes


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


generated by doc++