Image Component Library (ICL)
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
icl::utils::Mutex Class Reference

Mutex class of the ICL. More...

#include <Mutex.h>

Inheritance diagram for icl::utils::Mutex:
icl::utils::Uncopyable icl::utils::UncopiedInstance< icl::utils::Mutex >

Classes

class  Locker
 Locks a mutex on the stack (mutex is unlocked when the stack's section is released. More...
 

Public Types

enum  MutexType { mutexTypeNormal = PTHREAD_MUTEX_NORMAL, mutexTypeRecursive = PTHREAD_MUTEX_RECURSIVE }
 This enum holds available mutex types. More...
 

Public Member Functions

 Mutex (MutexType type=mutexTypeNormal)
 Create a mutex. More...
 
 ~Mutex ()
 Destroys the mutex. More...
 
void lock ()
 locks the mutex More...
 
int trylock ()
 locks the mutex without blocking. returns immediately. More...
 
void unlock ()
 unlocks the mutex More...
 

Public Attributes

enum icl::utils::Mutex::MutexType type
 

Private Attributes

pthread_mutex_t m
 wrapped thread_mutex_t struct More...
 
pthread_mutexattr_t a
 wrapped thread_mutexattr struct More...
 

Additional Inherited Members

- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Detailed Description

Mutex class of the ICL.

This mutex class is a simple object oriented wrapper of the pthread_mutex_t struct.

Mutices can be:

Member Enumeration Documentation

◆ MutexType

This enum holds available mutex types.

Enumerator
mutexTypeNormal 

normal mutex can not be locked by owner before unlocking

mutexTypeRecursive 

recursive mutex can be locked repeatedly by owner-thread. needs equal unlocks.

Constructor & Destructor Documentation

◆ Mutex()

icl::utils::Mutex::Mutex ( MutexType  type = mutexTypeNormal)
inline

Create a mutex.

Parameters
typeThe default MutexType is MutexType::mutexTypeNormal

◆ ~Mutex()

icl::utils::Mutex::~Mutex ( )
inline

Destroys the mutex.

Member Function Documentation

◆ lock()

void icl::utils::Mutex::lock ( )
inline

locks the mutex

◆ trylock()

int icl::utils::Mutex::trylock ( )
inline

locks the mutex without blocking. returns immediately.

Returns
zero if lock is acquired. otherwise an error-number

◆ unlock()

void icl::utils::Mutex::unlock ( )
inline

unlocks the mutex

Member Data Documentation

◆ a

pthread_mutexattr_t icl::utils::Mutex::a
private

wrapped thread_mutexattr struct

◆ m

pthread_mutex_t icl::utils::Mutex::m
private

wrapped thread_mutex_t struct

◆ type

enum icl::utils::Mutex::MutexType icl::utils::Mutex::type

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