Design Pattern Examples
Overview of object-oriented design patterns
mutex.h File Reference

Declaration of the Mutex structure and supporting functions for working with mutexes. More...

#include <stdbool.h>
Include dependency graph for mutex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Mutex
 Represents a handle to a mutex. Call mutex_create() to create the mutex and mutex_destroy() to destroy the mutex (when done with it). More...
 

Macros

#define __MUTEX_H__
 

Functions

bool mutex_create (Mutex *mutex)
 Create a new mutex, which is initially not owned.
 
bool mutex_destroy (Mutex *mutex)
 Destroy a previously created mutex.
 
bool mutex_lock (Mutex *mutex)
 Lock a previously created and unlocked mutex. This will block if the mutex is already locked by some other thread.
 
bool mutex_unlock (Mutex *mutex)
 Unlock a previously locked mutex.
 

Detailed Description

Declaration of the Mutex structure and supporting functions for working with mutexes.

Definition in file mutex.h.

Macro Definition Documentation

◆ __MUTEX_H__

#define __MUTEX_H__

Definition at line 7 of file mutex.h.

Function Documentation

◆ mutex_create()

bool mutex_create ( Mutex mutex)

Create a new mutex, which is initially not owned.

Parameters
mutexA Mutex object in which the mutex is created.
Returns
Returns true if the mutex was created; otherwise, returns false.

Definition at line 71 of file mutex.c.

References _allocate_mutex_handle(), and Mutex::handle.

Referenced by _CreateMutex().

◆ mutex_destroy()

bool mutex_destroy ( Mutex mutex)

Destroy a previously created mutex.

Parameters
mutexA Mutex object to destroy.
Returns
Returns true if the mutex was destroyed; otherwise, returns false.

Definition at line 128 of file mutex.c.

References _deallocate_mutex_handle(), _get_mutex_handle(), and Mutex::handle.

Referenced by _DestroyMutex().

◆ mutex_lock()

bool mutex_lock ( Mutex mutex)

Lock a previously created and unlocked mutex. This will block if the mutex is already locked by some other thread.

Parameters
mutexA Mutex object to lock.
Returns
Returns true if the mutex was locked; otherwise, returns false.

Definition at line 160 of file mutex.c.

References _get_mutex_handle(), and Mutex::handle.

Referenced by _LockMutex().

◆ mutex_unlock()

bool mutex_unlock ( Mutex mutex)

Unlock a previously locked mutex.

Parameters
mutexA Mutex object to unlock.
Returns
Returns true if the mutex was unlocked; otherwise, returns false.

Definition at line 197 of file mutex.c.

References _get_mutex_handle(), and Mutex::handle.

Referenced by _UnlockMutex().