SDL_UnlockRWLock(3)

✨ SDL_UnlockRWLock(3) ✨

okay bestie so this one is from the SDL3 FUNCTIONS collection β€” yeah, the manpage crew, manual name and all, we're just vibing here πŸ’…


🌸 NAME 🌸

SDL_UnlockRWLock β€” unlock the read/write lock. that's it. that's the whole job. πŸ”“


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_mutex.h>

void SDL_UnlockRWLock(SDL_RWLock *rwlock);

πŸ’– DESCRIPTION πŸ’–

Use this function to unlock the rwlock, and lowkey it does not care whether it was locked for read-only or write operations β€” either way, this is your girl. πŸ’…

Now here's the part where it gets cute: it is legal for the owning thread to lock an already-locked read-only lock. Yes bestie, she's re-entrant like that. ✨ But β€” and this is the catch β€” it must unlock it the same number of times before it is actually made available for other threads in the system. That's what they call a "recursive rwlock". Count your unlocks, fr fr. πŸ”’

⚠️ And now the scary part: it is illegal to unlock a rwlock that has not been locked by the current thread. Doing that = undefined behavior. Not "oopsie" behavior, not "probably fine" behavior β€” undefined. Do not. πŸš«πŸ’€

🫢 FUNCTION PARAMETERS 🫢

  • rwlock β€” the rwlock to unlock. the one. the only. your problematic fave. πŸŽ€

πŸ”₯ THREAD SAFETY πŸ”₯

This call must be paired with a previous locking call on the same thread. no solo unlocks. no unlocking someone else's lock. it's giving committed relationship, not situationship. 🫢✨


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. so if you're on something older, no she is not there, don't go looking. πŸ‘‘


πŸ’œ SEE ALSO πŸ’œ

go lock something, then come back and unlock it the same number of times. iykyk. πŸ¦‹


okay that's the whole page, and a lil sign-off for the credits because they ate: this came to you from Simple Directmedia Layer, version SDL 3.4.18 β€” iconic, no cap. mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from