SDL_WaitCondition(3)
π SDL_WaitCondition(3) π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, this one's about SDL_WaitCondition and it's lowkey the blueprint for how threads politely wait for each other π«Ά
β¨ NAME β¨
SDL_WaitCondition β wait until a condition variable is signaled. that's it, that's the whole vibe. sit there, look cute, wait for the signal π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_mutex.h>
void SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex);
π¦ DESCRIPTION π¦
so here's the tea β this function unlocks the specified mutex and then just waits for another thread to call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition variable cond. the way it's giving "i'll be right back, hold my spot" π
once the condition variable gets signaled, the mutex is re-locked and the function returns. like it left the group chat, got the notification, and immediately rejoined. no cap.
β οΈ bestie. the mutex must be locked before calling this function. locking the mutex recursively (more than once) is not supported and leads to undefined behavior. we do not do that here. π
and for the completionists: this function is the equivalent of calling SDL_WaitConditionTimeout() with a time length of -1. same energy, just the timeout flavor with the longest possible patience β¨
π FUNCTION PARAMETERS π
condβ the condition variable to wait on. the thing you're stalking. respectfully. πmutexβ the mutex used to coordinate thread access. the bouncer at the door, keeping everyone in line.
π THREAD SAFETY π
it is safe to call this function from any thread. literally any of them. everyone's invited, it's a whole party π
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on something older... babe, upgrade. π
π SEE ALSO π
SDL_BroadcastCondition(3)β yell the news to literally every waiting thread π’SDL_SignalCondition(3)β tap exactly one thread on the shoulderSDL_WaitConditionTimeout(3)β same thing but with a clock, because patience has limits β°
and that's the whole page, bestie!! this lil' slice of the manual lives in Simple Directmedia Layer's docs for SDL 3.4.18 β go forth and synchronize your threads responsibly π§ββοΈπβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms