sdlIsMainThread function

bool sdlIsMainThread()

Return whether this is the main thread.

On Apple platforms, the main thread is the thread that runs your program's main() entry point. On other platforms, the main thread is the one that calls SDL_Init(SDL_INIT_VIDEO), which should usually be the one that runs your program's main() entry point. If you are using the main callbacks, SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the main thread.

\returns true if this thread is the main thread, or false otherwise.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.2.0.

\sa SDL_RunOnMainThread

extern SDL_DECLSPEC bool SDLCALL SDL_IsMainThread(void)

Implementation

bool sdlIsMainThread() {
  final sdlIsMainThreadLookupFunction = libSdl3
      .lookupFunction<Uint8 Function(), int Function()>('SDL_IsMainThread');
  return sdlIsMainThreadLookupFunction() == 1;
}