Added SDL_ShouldInit() and SDL_ShouldQuit()

These are handy functions to support thread-safe initialization and shutdown.
This commit is contained in:
Sam Lantinga
2024-09-26 15:49:59 -07:00
parent 0e2c4e407a
commit 125e592844
7 changed files with 178 additions and 52 deletions

View File

@@ -47,24 +47,6 @@ extern bool SDL_endswith(const char *string, const char *suffix);
*/
extern int SDL_URIToLocal(const char *src, char *dst);
typedef enum SDL_InitStatus
{
SDL_INIT_STATUS_UNINITIALIZED,
SDL_INIT_STATUS_INITIALIZING,
SDL_INIT_STATUS_INITIALIZED,
SDL_INIT_STATUS_UNINITIALIZING
} SDL_InitStatus;
typedef struct SDL_InitState
{
SDL_AtomicInt status;
SDL_ThreadID thread;
} SDL_InitState;
extern bool SDL_ShouldInit(SDL_InitState *state);
extern bool SDL_ShouldQuit(SDL_InitState *state);
extern void SDL_SetInitialized(SDL_InitState *state, bool initialized);
typedef enum
{
SDL_OBJECT_TYPE_UNKNOWN,