SDL_LockRWLockForWriting(3)
π SDL_LockRWLockForWriting π
okay bestie, welcome to the SDL3 FUNCTIONS page for SDL_LockRWLockForWriting(3) β yes the whole manual name is in there, we're being β¨properβ¨ today.
πΈ NAME πΈ
SDL_LockRWLockForWriting β lock the read/write lock for write operations. that's it. that's the job. π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_mutex.h>
void SDL_LockRWLockForWriting(SDL_RWLock *rwlock);
β¨ DESCRIPTION β¨
so here's the tea β β this function will block until the rwlock is actually available, which means: not locked for reading or writing by any other thread. periodt.
Only one thread may hold the lock when it requests write access. everybody else β whether they also wanna write or they only want read-only access β has to wait until the writer thread has released the lock. no cutting the line, no exceptions. π«Ά
π¨ now the serious part, bestie, pay attention:
It is illegal for the owning thread to lock an already-locked rwlock for writing (read-only may be locked recursively, writing can not). Doing so results in undefined behavior. not "kinda weird behavior", not "a warning", literally undefined. do not. π
It is also illegal to request a write lock from a thread that already holds a read-only lock. Doing so results in undefined behavior. So unlock the read-only lock before you request a write lock. the order matters, iykyk. π
Okay but here's the comforting part: this function does not fail. if rwlock is NULL, it will return immediately having locked nothing. if the rwlock is valid, this function will always block until it can lock the mutex, and return with it locked. reliable king behavior. ππ
π FUNCTION PARAMETERS π
rwlockβ the read/write lock to lock. that's the one. the only one. give it the rwlock. πΈ
π THREAD SAFETY π
It is safe to call this function from any thread. yes, any. go wild (responsibly). β¨
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on something olderβ¦ girl. upgrade. π
π SEE ALSO π
go read those too, they're the friend group. π§
and that's the whole page, bestie!! this was brought to you by Simple Directmedia Layer, version SDL 3.4.18, on the SDL_LockRWLockForWriting(3) page. lock responsibly, unlock always, and remember: writing can NOT be recursive. mwah ππ
β¨
π¦ 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