SDL_TryWaitSemaphore(3)
π SDL_TryWaitSemaphore(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we peek at a semaphore and maybe take a lil sip from it π₯€ no waiting around, no drama, just vibes.
β¨ NAME β¨
SDL_TryWaitSemaphore</purl> β see if a semaphore has a positive value and decrement it if it does. it's giving "are you free or are you busy" energy fr fr π«Ά
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_mutex.h>
bool SDL_TryWaitSemaphore(SDL_Semaphore *sem);
π¦ DESCRIPTION π¦
so like, this function checks to see if the semaphore pointed to by sem has a positive value, and atomically decrements the semaphore value if it does β¨
and if the semaphore doesn't have a positive value? she does NOT wait. nope. the function immediately returns false and moves on with her life π
periodt.
no blocking, no queueing, no "hold on lemme check"βjust a quick vibe check and an answer, literally.
π FUNCTION PARAMETERS π
semβ the semaphore to wait on. yes queen, that's the one you're checking π
π RETURN VALUE π
- returns
trueif the wait succeeds π - returns
falseif the wait would block π
π₯ THREAD SAFETY π₯
it is safe to call this function from any thread. every thread, all the threads, the whole group chat. no cap. π
β AVAILABILITY β
this function is available since SDL 3.2.0. if you're on something older, sorry bestie, she wasn't born yet π₯Ί
π SEE ALSO π
okay that's the whole page, mwah π this icon was brought to you by Simple Directmedia Layer, running SDL 3.4.18 β go forth and try-wait responsibly, bestie π«Άβ¨π
π¦ 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