casacore
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::Mutex Class Reference

Wrapper around a pthreads mutex. More...

#include <Mutex.h>

Public Types

enum  Type {
  Normal,
  ErrorCheck,
  Recursive,
  Default,
  Auto
}
 Define the type of mutex. More...
 

Public Member Functions

 Mutex (Type type=Auto)
 Create the mutex. More...
 
 ~Mutex ()
 Destroy the mutex. More...
 
void lock ()
 Set a lock on the mutex. More...
 
void unlock ()
 Unlock the mutex. More...
 
bool trylock ()
 Try to lock the mutex. More...
 

Private Member Functions

 Mutex (const Mutex &)
 Forbid copy constructor. More...
 
Mutexoperator= (const Mutex &)
 Forbid assignment. More...
 

Private Attributes

void * itsMutex
 

Detailed Description

Wrapper around a pthreads mutex.

Intended use:

Public interface

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Synopsis

This class is a wrapper around a phtreads mutex.
Although the Mutex class has a lock function, class ScopedMutexLock should be used to obtain a lock, because it makes locking exception-safe.

Definition at line 49 of file Mutex.h.

Member Enumeration Documentation

Define the type of mutex.

(see phtread_mutexattr_settype for their meaning). In Debug mode, type Auto will use PTHREAD_MUTEX_ERRORCHECK, otherwise PTHREAD_MUTEX_DEFAULT.

Enumerator
Normal 
ErrorCheck 
Recursive 
Default 
Auto 

Definition at line 56 of file Mutex.h.

Constructor & Destructor Documentation

casacore::Mutex::Mutex ( Type  type = Auto)

Create the mutex.

casacore::Mutex::~Mutex ( )

Destroy the mutex.

casacore::Mutex::Mutex ( const Mutex )
private

Forbid copy constructor.

Member Function Documentation

void casacore::Mutex::lock ( )

Set a lock on the mutex.

It waits till it gets the lock.

Mutex& casacore::Mutex::operator= ( const Mutex )
private
bool casacore::Mutex::trylock ( )

Try to lock the mutex.

True is returned if it succeeded.

void casacore::Mutex::unlock ( )

Unlock the mutex.

Member Data Documentation

void* casacore::Mutex::itsMutex
private

Definition at line 81 of file Mutex.h.

Referenced by casacore::MutexedInit::mutex().


The documentation for this class was generated from the following file: