c++-gtk-utils

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

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

Public Member Functions | List of all members
Cgu::Thread::GrecmutexLock Class Reference

A scoped locking class for exception safe locking of GStaticRecMutex objects. More...

`#include <c++-gtk-utils/mutex.h>`

## Public Member Functions
| GrecmutexLock (const GrecmutexLock &)=delete
GrecmutexLock & | operator= (const GrecmutexLock &)=delete
GStaticRecMutex * | get () const noexcept
| GrecmutexLock (GStaticRecMutex &mutex_)
| GrecmutexLock (GStaticRecMutex &mutex_, Locked tag)
| GrecmutexLock ()=delete
| ~GrecmutexLock ()

## Detailed Description

A scoped locking class for exception safe locking of GStaticRecMutex objects.

This class is mainly intended for use where the native pthreads implementation does not support recursive mutexes so Cgu::Thread::RecMutex and Cgu::Thread::RecMutex::Lock cannot be used.

It should be noted that this class is for use with GStaticRecMutex objects, and not the GRecMutex objects available in glib from glib version 2.32. If glib >= 2.32 is installed, it can be assumed that native recursive mutexes and so Cgu::Thread::RecMutex are available, as glib >= 2.32 also uses native recursive mutexes.

## Constructor & Destructor Documentation

## ◆ GrecmutexLock() [1/4]

Cgu::Thread::GrecmutexLock::GrecmutexLock | ( | const GrecmutexLock & |  | ) |
| delete

This class cannot be copied. The copy constructor is deleted.

## ◆ GrecmutexLock() [2/4]

Cgu::Thread::GrecmutexLock::GrecmutexLock | ( | GStaticRecMutex & | mutex_ | ) |

This constructor locks the mutex and acquires ownership, and blocks if it is already locked until it becomes free, unless the constructing thread already holds the lock, in which case it increments the lock count and returns immediately. It is not a cancellation point. It does not throw.

Parameters

  mutex_ | The mutex to be locked.

## ◆ GrecmutexLock() [3/4]

Cgu::Thread::GrecmutexLock::GrecmutexLock | ( | GStaticRecMutex & | mutex_,
|  | Locked | tag
| ) |  |
| inline

This constructor takes an already locked mutex (say as a result of g_static_rec_mutex_trylock()), and takes ownership of it. It is not a cancellation point. It does not throw.

Parameters

  mutex_ | The mutex to be managed by this object.
  tag | Pass the Cgu::Thread::locked enum tag to this parameter.

## ◆ GrecmutexLock() [4/4]

Cgu::Thread::GrecmutexLock::GrecmutexLock | ( |  | ) |
| delete

This class requires initialisation with a GStaticRecMutex. The default constructor is deleted.

## ◆ ~GrecmutexLock()

Cgu::Thread::GrecmutexLock::~GrecmutexLock | ( |  | ) |

The destructor unlocks the owned mutex, and either relinquishes ownership (if the mutex has not been recursively locked) or decrements the lock count (if it has). It is not a cancellation point. It does not throw.

## Member Function Documentation

## ◆ get()

GStaticRecMutex* Cgu::Thread::GrecmutexLock::get | ( |  | ) | const
| inline noexcept

This method provides access to the GStaticRecMutex object locked by this GrecmutexLock object. It does not throw. It is thread safe.

Returns
  A pointer to the GStaticRecMutex object.

## ◆ operator=()

GrecmutexLock& Cgu::Thread::GrecmutexLock::operator= | ( | const GrecmutexLock & |  | ) |
| delete

This class cannot be copied. The assignment operator is deleted.

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

- mutex.h