Added thread-safe initialization/cleanup support

Also went through and removed inappropriate uses of spinlocks.

Fixes https://github.com/libsdl-org/SDL/issues/10872
This commit is contained in:
Sam Lantinga
2024-09-16 22:45:37 -07:00
parent 7edd43c276
commit 9275c533ca
7 changed files with 208 additions and 132 deletions

View File

@@ -47,6 +47,24 @@ 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,