TinyThread++: mutex Class Reference

# mutex Class Reference

Mutex class. More...

`#include <tinythread.h>`

List of all members.

## Public Member Functions
| mutex ()
| Constructor.
| ~mutex ()
| Destructor.
void | lock ()
| Lock the mutex.
bool | try_lock ()
| Try to lock the mutex.
void | unlock ()
| Unlock the mutex.

## Detailed Description

Mutex class.

This is a mutual exclusion object for synchronizing access to shared memory areas for several threads. The mutex is non-recursive (i.e. a program may deadlock if the thread that owns a mutex object calls lock() on that object).

See also:
  recursive_mutex

## Member Function Documentation

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

Lock the mutex.

The method will block the calling thread until a lock on the mutex can be obtained. The mutex remains locked until `unlock()` is called.

See also:
  lock_guard

bool try_lock | ( |  | ) | `[inline]`

Try to lock the mutex.

The method will try to lock the mutex. If it fails, the function will return immediately (non-blocking).

Returns:
  `true` if the lock was acquired, or `false` if the lock could not be acquired.

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

Unlock the mutex.

If any threads are waiting for the lock on this mutex, one of them will be unblocked.

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

- tinythread.h