SDL_InitState Struct Reference

`#include <SDL_mutex.h>`

Collaboration diagram for SDL_InitState:
[legend]

## Data Fields

SDL_AtomicInt | status
SDL_ThreadID | thread
void * | reserved

## Detailed Description

A structure used for thread-safe initialization and shutdown.

Here is an example of using this:

static SDL_InitState init;
bool InitSystem(void)
{
if (!SDL_ShouldInit(&init)) {
// The system is initialized
return true;
}
// At this point, you should not leave this function without calling SDL_SetInitialized()
bool initialized = DoInitTasks();
SDL_SetInitialized(&init, initialized);
return initialized;
}
bool UseSubsystem(void)
{
if (SDL_ShouldInit(&init)) {
// Error, the subsystem isn't initialized
SDL_SetInitialized(&init, false);
return false;
}
// Do work using the initialized subsystem
return true;
}
void QuitSystem(void)
{
if (!SDL_ShouldQuit(&init)) {
// The system is not initialized
return;
}
// At this point, you should not leave this function without calling SDL_SetInitialized()
DoQuitTasks();
SDL_SetInitialized(&init, false);
}
SDL_ShouldInit
bool SDL_ShouldInit(SDL_InitState *state)
SDL_SetInitialized
void SDL_SetInitialized(SDL_InitState *state, bool initialized)
SDL_ShouldQuit
bool SDL_ShouldQuit(SDL_InitState *state)
SDL_InitState
Definition SDL_mutex.h:1038

Note that this doesn't protect any resources created during initialization, or guarantee that nobody is using those resources during cleanup. You should use other mechanisms to protect those, if that's a concern for your code.

Since
  This struct is available since SDL 3.2.0.

Definition at line 1037 of file SDL_mutex.h.

## Field Documentation

## reserved

void* SDL_InitState::reserved

Definition at line 1041 of file SDL_mutex.h.

## status

SDL_AtomicInt SDL_InitState::status

Definition at line 1039 of file SDL_mutex.h.

## thread

SDL_ThreadID SDL_InitState::thread

Definition at line 1040 of file SDL_mutex.h.

The documentation for this struct was generated from the following file:

- SDL_mutex.h