cgv
Loading...
Searching...
No Matches
cgv::os::mutex Struct Reference

A simple mutex (mutual exclusion) for solving thread synchronisation problems. More...

#include <mutex.h>

Inheritance diagram for cgv::os::mutex:
cgv::os::condition_mutex

Public Member Functions

 mutex ()
 construct a mutex
 
 ~mutex ()
 destruct a mutex
 
bool try_lock ()
 try to lock the mutex (return false if the mutex is still locked)
 
void lock ()
 lock the mutex (if the mutex is already locked, the caller is blocked until the mutex becomes available)
 
void unlock ()
 unlock the mutex
 
void debug_lock (const std::string &info)
 same as lock but with printing debug information
 
void debug_unlock (const std::string &info)
 same unlock but with printing debug information
 

Static Public Member Functions

static unsigned get_debug_lock_counter ()
 return the global locking counter that is used for mutex debugging
 

Protected Attributes

void * pmutex
 

Detailed Description

A simple mutex (mutual exclusion) for solving thread synchronisation problems.

Definition at line 13 of file mutex.h.

Constructor & Destructor Documentation

◆ mutex()

cgv::os::mutex::mutex ( )

construct a mutex

Definition at line 27 of file mutex_pthread.h.

◆ ~mutex()

cgv::os::mutex::~mutex ( )

destruct a mutex

Definition at line 33 of file mutex_pthread.h.

Member Function Documentation

◆ debug_lock()

void cgv::os::mutex::debug_lock ( const std::string &  info)

same as lock but with printing debug information

Definition at line 52 of file mutex_pthread.h.

References get_debug_lock_counter(), lock(), and unlock().

◆ debug_unlock()

void cgv::os::mutex::debug_unlock ( const std::string &  info)

same unlock but with printing debug information

Definition at line 64 of file mutex_pthread.h.

References lock(), and unlock().

◆ get_debug_lock_counter()

unsigned cgv::os::mutex::get_debug_lock_counter ( )
static

return the global locking counter that is used for mutex debugging

Definition at line 21 of file mutex_pthread.h.

Referenced by debug_lock().

◆ lock()

◆ try_lock()

bool cgv::os::mutex::try_lock ( )

try to lock the mutex (return false if the mutex is still locked)

Definition at line 74 of file mutex_pthread.h.

◆ unlock()

Member Data Documentation

◆ pmutex

void* cgv::os::mutex::pmutex
protected

Definition at line 16 of file mutex.h.


The documentation for this struct was generated from the following files: