libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches

Platform independent mutex implementation. More...

Data Fields

void(* Lock )(CMUTIL_Mutex *mutex)
 Lock this mutex object.
 
void(* Unlock )(CMUTIL_Mutex *mutex)
 Unlock this mutex object.
 
CMBool(* TryLock )(CMUTIL_Mutex *mutex)
 Try to lock the given mutex object.
 
void(* Destroy )(CMUTIL_Mutex *mutex)
 Destroys all resources related to this object.
 

Detailed Description

Platform independent mutex implementation.

Field Documentation

◆ Lock

void(* CMUTIL_Mutex::Lock) (CMUTIL_Mutex *mutex)

Lock this mutex object.

This mutex object shall be locked. If this mutex is already locked by another thread, the calling thread shall block until this mutex becomes available. This method shall return with this mutex object in the locked state with the calling thread as its owner.

This mutex is a recursive lockable object. This mutex shall maintain the concept of lock count. When a thread successfully acquires a mutex for the first time, the lock count shall be set to one. Every time a thread relocks this mutex, the lock count shall be incremented by one. Each time the thread unlocks the mutex, the lock count shall be decremented by one. When the lock count reaches zero, the mutex shall become available for other threads to acquire.

Parameters
mutexThis mutex object.

◆ Unlock

void(* CMUTIL_Mutex::Unlock) (CMUTIL_Mutex *mutex)

Unlock this mutex object.

This mutex object shall be unlocked if the lock count reaches zero.

Parameters
mutexThis mutex object.

◆ TryLock

CMBool(* CMUTIL_Mutex::TryLock) (CMUTIL_Mutex *mutex)

Try to lock the given mutex object.

Parameters
mutexa mutex object to be tested.
Returns
CMTrue if mutex locked successfully, CMFalse if another thread locked this mutex already, so the locking is failed.

◆ Destroy

void(* CMUTIL_Mutex::Destroy) (CMUTIL_Mutex *mutex)

Destroys all resources related to this object.

Parameters
mutexThis mutex object.

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