SDL_TryLockRWLockForReading(3)
π SDL_TryLockRWLockForReading(3) β¨
aka the SDL3 function that's like "hey bestie, you free rn?" instead of standing there waiting forever π
πΈ NAME πΈ
SDL_TryLockRWLockForReading β try to lock a read/write lock for reading without blocking. no waiting, no lines, no drama π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_mutex.h>
bool SDL_TryLockRWLockForReading(SDL_RWLock *rwlock);
β¨ DESCRIPTION β¨
Okay so this works exactly like SDL_LockRWLockForReading(), except β and this is the whole moment β if the rwlock is not available, this function bails and returns false immediately. immediately immediately. Not "after a bit". Not "when it's polite". Right now. π
This technique is useful if you need access to a resource but you don't want to wait around for it, and you'll come back and try again later. Like texting "u up?" and if they don't answer you just... go do something else. Main character energy honestly. π
Trying to lock for read-only access can succeed even if other threads are holding read-only locks, because read-only stuff doesn't block other read-only stuff β nobody's fighting, everyone's just vibing with their own copy. π«Ά
And a lil fun fact that lowkey matters: this function returns true if you pass it a NULL rwlock. Yes really. NULL gets the slay treatment. π
π FUNCTION PARAMETERS π
rwlockβ the rwlock you're trying to lock, bestie. the one and only. π
π RETURN VALUE π
Returns true on success, and false if the lock would block. That's it. That's the whole vibe check. β¨
π₯ THREAD SAFETY π₯
It is safe to call this function from any thread. any thread. every thread. go off, all of you. π
π AVAILABILITY π
This function is available since SDL 3.2.0. so if your SDL is older than that, she's not here yet, sorry bestie π
π SEE ALSO π
mwah π this page came to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 β stan an iconic library bestie, she's been holding it down fr fr πΈβ¨π
π¦ 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