head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.36; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.50; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.53.59; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.54; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# SGMutex Class Reference

A mutex is used to protect a section of code such that at any time only a single thread can execute the code. More...

`#include <SGThread.hxx>`

List of all members.

## Public Methods
| SGMutex ()
| Create a new mutex.
| ~SGMutex ()
| Destroy a mutex object.
void | lock ()
| Lock this mutex.
bool | trylock ()
| Try to lock the mutex for the current thread.
void | unlock ()
| Unlock this mutex.
## Protected Attributes
pthread_mutex_t | mutex
| Pthread mutex.
## Friends
class | SGCondition

## Detailed Description

A mutex is used to protect a section of code such that at any time only a single thread can execute the code.

Definition at line 158 of file SGThread.hxx.

## Constructor & Destructor Documentation

SGMutex::SGMutex | ( |  | ) | `[inline]`

| Create a new mutex. Under Linux this is a 'fast' mutex. Definition at line 212 of file SGThread.hxx. References mutex.

SGMutex::~SGMutex | ( |  | ) | `[inline]`

| Destroy a mutex object. Note: it is the responsibility of the caller to ensure the mutex is unlocked before destruction occurs. Definition at line 218 of file SGThread.hxx. References mutex.

## Member Function Documentation

void SGMutex::lock | ( |  | ) | `[inline]`

| Lock this mutex. If the mutex is currently unlocked, it becomes locked and owned by the calling thread. If the mutex is already locked by another thread, the calling thread is suspended until the mutex is unlocked. If the mutex is already locked and owned by the calling thread, the calling thread is suspended until the mutex is unlocked, effectively causing the calling thread to deadlock. See also: SGMutex::trylock Definition at line 224 of file SGThread.hxx. References mutex.

bool SGMutex::trylock | ( |  | ) |

| Try to lock the mutex for the current thread. Behaves like lock except that it doesn't block the calling thread. Returns: true if mutex was successfully locked, otherwise false. See also: SGMutex::lock Definition at line 41 of file SGThread.cxx. References mutex.

void SGMutex::unlock | ( |  | ) | `[inline]`

| Unlock this mutex. It is assumed that the mutex is locked and owned by the calling thread. Definition at line 230 of file SGThread.hxx. References mutex. Referenced by SGBlockingQueue< T >::~SGBlockingQueue().

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

- SGThread.hxx
- SGThread.cxx

@ 1.3 log @Oops, try again. @ text @d223 1 a223 1