glibmm 2.34.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Glib::Threads::Mutex::Lock Class Reference
Threads

Utility class for exception-safe mutex locking. More...

`#include <glibmm/threads.h>`

## Public Member Functions

| Lock (Mutex& mutex)
| Lock (Mutex& mutex, NotLock)
| Lock (Mutex& mutex, TryLock)
| ~Lock ()
void | acquire ()
bool | try_acquire ()
void | release ()
bool | locked () const

## Detailed Description

Utility class for exception-safe mutex locking.

Usage example:
  {
  Glib::Mutex::Lock lock (mutex); // calls mutex.lock()
  do_something();
  } // the destructor calls mutex.unlock()
  As you can see, the compiler takes care of the unlocking. This is not only exception safe but also much less error-prone. You could even `return` while still holding the lock and it will be released properly.

Examples:
  thread/thread.cc.

## Constructor & Destructor Documentation

Glib::Threads::Mutex::Lock::Lock | ( | Mutex& | mutex | ) |

inline explicit

Glib::Threads::Mutex::Lock::Lock | ( | Mutex& | mutex,
|  | NotLock |
| ) |  |

inline

Glib::Threads::Mutex::Lock::Lock | ( | Mutex& | mutex,
|  | TryLock |
| ) |  |

inline

Glib::Threads::Mutex::Lock::~Lock | ( |  | ) |

inline

## Member Function Documentation

void Glib::Threads::Mutex::Lock::acquire | ( |  | ) |

inline

bool Glib::Threads::Mutex::Lock::locked | ( |  | ) | const

inline

void Glib::Threads::Mutex::Lock::release | ( |  | ) |

inline

bool Glib::Threads::Mutex::Lock::try_acquire | ( |  | ) |

inline