SDL_IsMainThread(3)

πŸ’– SDL_IsMainThread(3) πŸ’–

okay so we're in the SDL3 FUNCTIONS manual, bestie, and this page is literally about SDL_IsMainThread. It's giving "am I the main character thread?" energy, and honestly? Iconic question. ✨


🌸 NAME 🌸

SDL_IsMainThread β€” return whether this is the main thread. Like, are you that thread or not? 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_init.h>

bool SDL_IsMainThread(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie. On Apple platforms, the main thread is the thread that runs your program's main() entry point. Periodt.

On other platforms, the main thread is the one that calls SDL_Init([SDL_INIT_VIDEO](SDL_INIT_VIDEO)), which should usually be the one that runs your program's main() entry point. No cap.

If you are using the main callbacks, SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the main thread. So yes, they're all chilling on the main thread together. πŸ’…


πŸ’… RETURN VALUE πŸ’…

Returns true if this thread is the main thread, or false otherwise. That's it. Binary. No cap. πŸ’–


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. Slay. ✨


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. So if you're on something older? Ma'am. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯


bye bestie 🫢 β€” Simple Directmedia Layer β€’ SDL 3.4.18 β€’ SDL_IsMainThread(3)

πŸ“¦ where this page comes from