SDL_GetTLS(3)

πŸ’– SDL_GetTLS πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section, we're talking about SDL_GetTLS and honestly it's giving "little function, big feelings."

✨ NAME ✨

SDL_GetTLS β€” get the current thread's value associated with a thread local storage ID πŸ§΅πŸ’…

like. it fetches your thread's lil stash. nobody else's. just yours. periodt.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_thread.h>

void * SDL_GetTLS(SDL_TLSID *id);

there she is. one function, one pointer in, one pointer out. iconic behavior fr fr πŸŽ€


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • id β€” a pointer to the thread local storage ID, and bestie listen to me: it may not be NULL. do not pass NULL. that's not a vibe check you wanna fail πŸ™ˆ

⭐ RETURN VALUE ⭐

It returns the value associated with the ID for the current thread, or NULL if no value has been set.

and if you get NULL and you're like "wait was that an error or was that just empty πŸ₯Ί" β€” call SDL_GetError() for more information. she'll tell you what's up, no cap.

ngl NULL here is doing double duty: "nothing was set" and possibly "something went wrong." that's why you gotta go ask SDL_GetError(). it's giving mysterious on purpose πŸ’€

🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. literally any thread. every thread. all the threads. main character energy for every single one of them πŸ‘‘


πŸ“ AVAILABILITY πŸ“

This function is available since SDL 3.2.0. so if you're on something older, sorry babe, this one's not for you yet 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_SetTLS(3) β€” the other half of the duo, the one that puts the value there in the first place. you two are a matching set, iykyk πŸ’œ

and that's the whole page, bestie!! written up under the Simple Directmedia Layer umbrella, for SDL 3.4.18 β€” mwah, go forth and thread-local-storage responsibly πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from