libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Mutex.cpp
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * Mutex.cpp
5 *
6 * Generic - Everything platform-specific lives behind platform->getThread().
7 ***************************************************************************/
8#include "Platform.h"
9
10Mutex::Mutex()
11{
12 if(platform && platform->getThread())
13 handle = platform->getThread()->createMutex();
14}
15
16Mutex::~Mutex()
17{
18 if(handle && platform && platform->getThread())
19 platform->getThread()->destroyMutex(handle);
20}
21
23{
24 if(handle && platform && platform->getThread())
25 platform->getThread()->lockMutex(handle);
26}
27
29{
30 if(handle && platform && platform->getThread())
31 platform->getThread()->unlockMutex(handle);
32}
void unlock()
Releases the mutex. Must be called by the thread that locked it.
Definition Mutex.cpp:28
void * handle
Backend-assigned mutex handle.
Definition Mutex.h:29
void lock()
Blocks until the mutex is acquired. Not recursive: locking twice from one thread deadlocks.
Definition Mutex.cpp:22
virtual ThreadDriver * getThread()=0
virtual void * createMutex()=0
Creates an unlocked mutex.
virtual void destroyMutex(void *mutex)=0
Destroys a mutex created by createMutex(). It must not be locked.