Implementation of the functions used for working with the Mutex structure that deal with mutexes. More...
Go to the source code of this file.
Macros | |
#define | MUTEX_TYPE mtx_t |
Functions | |
static MUTEX_TYPE | _get_mutex_handle (void *handle) |
Helper function to retrieve the mutex handle from the given memory pointer. | |
static void * | _allocate_mutex_handle (MUTEX_TYPE handle) |
Helper function to allocate memory from the heap in which to store the given mutex handle. Returns the pointer to the memory containing the mutex handle. | |
static void | _deallocate_mutex_handle (void *handle) |
Helper function to deallocate memory that contained a mutex handle. The mutex handle itself should be destroyed through normal means. | |
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. | |
Implementation of the functions used for working with the Mutex structure that deal with mutexes.
Definition in file mutex.c.
|
static |
Helper function to allocate memory from the heap in which to store the given mutex handle. Returns the pointer to the memory containing the mutex handle.
handle | The handle to the mutex to store. |
Definition at line 46 of file mutex.c.
References MUTEX_TYPE.
Referenced by mutex_create().
|
static |
Helper function to deallocate memory that contained a mutex handle. The mutex handle itself should be destroyed through normal means.
handle | Pointer to the memory holding a mutex handle. |
Definition at line 61 of file mutex.c.
Referenced by mutex_destroy().
|
static |
Helper function to retrieve the mutex handle from the given memory pointer.
handle | Pointer to the memory containing the mutex handle. Cannot be NULL. |
Definition at line 34 of file mutex.c.
References MUTEX_TYPE.
Referenced by mutex_destroy(), mutex_lock(), and mutex_unlock().
bool mutex_create | ( | Mutex * | mutex | ) |
Create a new mutex, which is initially not owned.
mutex | A Mutex object in which the mutex is created. |
Definition at line 71 of file mutex.c.
References _allocate_mutex_handle(), and Mutex::handle.
Referenced by _CreateMutex().
bool mutex_destroy | ( | Mutex * | mutex | ) |
Destroy a previously created mutex.
mutex | A Mutex object to destroy. |
Definition at line 128 of file mutex.c.
References _deallocate_mutex_handle(), _get_mutex_handle(), and Mutex::handle.
Referenced by _DestroyMutex().
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.
mutex | A Mutex object to lock. |
Definition at line 160 of file mutex.c.
References _get_mutex_handle(), and Mutex::handle.
Referenced by _LockMutex().
bool mutex_unlock | ( | Mutex * | mutex | ) |
Unlock a previously locked mutex.
mutex | A Mutex object to unlock. |
Definition at line 197 of file mutex.c.
References _get_mutex_handle(), and Mutex::handle.
Referenced by _UnlockMutex().