SDL_WaitSemaphoreTimeout(3)
β¨ SDL_WaitSemaphoreTimeout(3) β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, where we learn how to make threads politely take turns π
πΈ NAME πΈ
SDL_WaitSemaphoreTimeout β wait until a semaphore has a positive value and then decrements it.
no cap, that's literally the whole vibe. it waits, and then it takes one. π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_mutex.h>
bool SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS);
π DESCRIPTION π
okay so here's the tea: this function suspends the calling thread β like, puts it in time-out, napping, not doing anything β until one of two things happens:
- the semaphore pointed to by
semhas a positive value, or - the specified time has elapsed.
and the way that it's atomic about the decrement? iconic. if the call is successful it will atomically decrement the semaphore value, meaning nobody can sneak in and mess with it mid-step. it's giving main character energy, it's giving thread-safe precision, it's giving π«Ά
π FUNCTION PARAMETERS π
semβ the semaphore to wait on. that's your girl, the one you're queuing up for.timeoutMSβ the length of the timeout, in milliseconds, or-1to wait indefinitely. yes,-1means "bestie i will wait forever, take your time" π
β RETURN VALUE β
Returns true if the wait succeeds, or false if the wait times out.
that's it. that's the whole report card. no extra lore, no hidden fields. π
π₯ THREAD SAFETY π₯
It is safe to call this function from any thread. any thread!! every thread!! the whole group chat can call it and nothing bad happens. periodt. π
π AVAILABILITY π
This function is available since SDL 3.2.0. so if you're on something older, sorry babes, you're not invited to this party π
π SEE ALSO π
go read those too, they're the supporting cast and they ate. π
Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_WaitSemaphoreTimeout(3)
mwah, that's a wrap bestie π§β¨ go forth and semaphore responsibly, and remember: atomic decrements are the love language π
π¦ 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