sdlRunOnMainThread function
- Pointer<
NativeFunction< callback,SdlMainThreadCallback> > - Pointer<
NativeType> userdata, - bool waitComplete
Call a function on the main thread during event processing.
If this is called on the main thread, the callback is executed immediately. If this is called on another thread, this callback is queued for execution on the main thread during event processing.
Be careful of deadlocks when using this functionality. You should not have
the main thread wait for the current thread while this function is being
called with wait_complete
true.
\param callback the callback to call on the main thread.
\param userdata a pointer that is passed to callback
.
\param wait_complete true to wait for the callback to complete, false to
return immediately.
\returns true on success or false on failure; call SDL_GetError() for more
information.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.2.0.
\sa SDL_IsMainThread
extern SDL_DECLSPEC bool SDLCALL SDL_RunOnMainThread(SDL_MainThreadCallback callback, void *userdata, bool wait_complete)
Implementation
bool sdlRunOnMainThread(Pointer<NativeFunction<SdlMainThreadCallback>> callback,
Pointer<NativeType> userdata, bool waitComplete) {
final sdlRunOnMainThreadLookupFunction = libSdl3.lookupFunction<
Uint8 Function(Pointer<NativeFunction<SdlMainThreadCallback>> callback,
Pointer<NativeType> userdata, Uint8 waitComplete),
int Function(
Pointer<NativeFunction<SdlMainThreadCallback>> callback,
Pointer<NativeType> userdata,
int waitComplete)>('SDL_RunOnMainThread');
return sdlRunOnMainThreadLookupFunction(
callback, userdata, waitComplete ? 1 : 0) ==
1;
}