---
name: "MutexLock"
section: "3cc"
platform: "linux"
package: "libcommoncpp2-dev"
version: "1.0.13-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/MutexLock"
---

# MutexLock(3cc)

The MutexLock class is used to protect a section of code so that at any given time only a single thread can perform the protected operation. Mutex automatic locker for protected access.

## NAME

MutexLock - The MutexLock class is used to protect a section of code so that at any given time only a single thread can perform the protected operation. **Mutex** automatic locker for protected access.

## SYNOPSIS

`#include <thread.h>`

### Public Methods

**MutexLock** (**Mutex** &\_mutex)\
 *Acquire the mutex.* **~MutexLock** ()\
 *Release the mutex automatically.*

## DETAILED DESCRIPTION

The MutexLock class is used to protect a section of code so that at any given time only a single thread can perform the protected operation. **Mutex** automatic locker for protected access.

It use **Mutex** to protect operation. Using this class is usefull and  exception safe.

A common use is

void func\_to\_protect() { MutexLock lock(mutex); ... operation ... }

NOTE: do not declare variable as 'MutexLock (mutex)', the mutex will be  released at statement end.

**Author:**  Frediano Ziglio \<freddy77@angelfire.com\>

## CONSTRUCTOR & DESTRUCTOR DOCUMENTATION

### MutexLock::MutexLock (Mutex & \_mutex)` [inline]`

Acquire the mutex.

### MutexLock::~MutexLock ()` [inline]`

Release the mutex automatically.

## AUTHOR

Generated automatically by Doxygen for CommonC++ from the source code.
