SDL_ThreadState(3type)

πŸ’– SDL_ThreadState(3type) πŸ’–

okay bestie, gather round, because we're talking about SDL_ThreadState β€” yes it's a 3type page, yes it's from the SDL3 DATATYPES girlies, and yes it's lowkey one of the most useful little enums you'll ever meet. it's the state of an SDL thread. that's it. that's the whole vibe. 🧡✨


✨ SYNOPSIS ✨

like all good things, it starts with an include:

#include <SDL3/SDL_thread.h>

typedef enum SDL_ThreadState
{
    SDL_THREAD_UNKNOWN,     /**< The thread is not valid */
    SDL_THREAD_ALIVE,       /**< The thread is currently running */
    SDL_THREAD_DETACHED,    /**< The thread is detached and can't be waited on */
    SDL_THREAD_COMPLETE     /**< The thread has finished and should be cleaned up with SDL_WaitThread() */
} SDL_ThreadState;

and now let's go through the squad one by one, because each of these is giving a very specific energy:

  • SDL_THREAD_UNKNOWN β€” the thread is not valid. not a real one. we don't know her. 🚫
  • SDL_THREAD_ALIVE β€” she's currently running. main character energy, actively doing the thing. πŸ”₯
  • SDL_THREAD_DETACHED β€” she's detached and can't be waited on. do not try to wait on this one, bestie, she's booked and busy and you have no join rights. πŸ’…
  • SDL_THREAD_COMPLETE β€” she has finished, and she should be cleaned up with SDL_WaitThread(). she did her job, now go be a good citizen and tidy up. 🧹

🌸 DESCRIPTION 🌸

so how do you actually check which state a thread is in?? you call SDL_GetThreadState, that's the move. the current state of a thread can be checked by calling SDL_GetThreadState. periodt. 🫢


πŸ¦‹ AVAILABILITY πŸ¦‹

this enum is available since SDL 3.2.0. so if you're on anything older, no she's not there yet, upgrade bestie. 🌈


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’€ reminder that SDL_THREAD_DETACHED means no waiting allowed β€” if you try to wait on a detached thread that's a you problem, not hers.

okay and that's the whole page, you ate it, you understood it, iconic. this little datatype comes to you from Simple Directmedia Layer (yes, the SDL 3.4.18 era πŸ’œ), and the page itself is SDL_ThreadState(3type). go forth and check your thread states, bestie, ily, bye! πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from