libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Cond.cpp
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * Cond.cpp
5 *
6 * Generic - Everything platform-specific lives behind platform->getThread().
7 ***************************************************************************/
8#include "Platform.h"
9#include "Cond.h"
10
11Cond::Cond()
12{
13 if(platform && platform->getThread())
14 handle = platform->getThread()->createCond();
15}
16
17Cond::~Cond()
18{
19 if(handle && platform && platform->getThread())
20 platform->getThread()->destroyCond(handle);
21}
22
23void Cond::wait(Mutex & lock)
24{
25 if(handle && lock.handle && platform && platform->getThread())
26 platform->getThread()->waitCond(handle, lock.handle);
27}
28
30{
31 if(handle && platform && platform->getThread())
32 platform->getThread()->signalCond(handle);
33}
void signal()
Wakes every thread currently blocked in wait() on this condition variable.
Definition Cond.cpp:29
void * handle
Backend-assigned condition variable handle.
Definition Cond.h:35
void wait(Mutex &lock)
Unlocks lock and blocks until signal() is called, then reacquires lock before returning.
Definition Cond.cpp:23
A simple mutual-exclusion lock.
Definition Mutex.h:14
void * handle
Backend-assigned mutex handle.
Definition Mutex.h:29
virtual ThreadDriver * getThread()=0
virtual void destroyCond(void *cond)=0
Destroys a condition variable created by createCond(). No thread may be waiting on it.
virtual void * createCond()=0
Creates a condition variable.