sdlCreateThreadRuntime function thread

Pointer<SdlThread> sdlCreateThreadRuntime(
  1. Pointer<NativeFunction<SdlThreadFunction>> fn,
  2. String? name,
  3. Pointer<NativeType> data,
  4. Pointer<NativeType> pfnBeginThread,
  5. Pointer<NativeType> pfnEndThread,
)

The actual entry point for SDL_CreateThread.

\param fn the SDL_ThreadFunction function to call in the new thread \param name the name of the thread \param data a pointer that is passed to fn \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL. \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL. \returns an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call SDL_GetError() for more information.

\since This function is available since SDL 3.2.0.

extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadRuntime(SDL_ThreadFunction fn, const char *name, void *data, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread)

Implementation

Pointer<SdlThread> sdlCreateThreadRuntime(
  Pointer<NativeFunction<SdlThreadFunction>> fn,
  String? name,
  Pointer<NativeType> data,
  Pointer<NativeType> pfnBeginThread,
  Pointer<NativeType> pfnEndThread,
) {
  final sdlCreateThreadRuntimeLookupFunction = _libSdl
      .lookupFunction<
        Pointer<SdlThread> Function(
          Pointer<NativeFunction<SdlThreadFunction>> fn,
          Pointer<Utf8> name,
          Pointer<NativeType> data,
          Pointer<NativeType> pfnBeginThread,
          Pointer<NativeType> pfnEndThread,
        ),
        Pointer<SdlThread> Function(
          Pointer<NativeFunction<SdlThreadFunction>> fn,
          Pointer<Utf8> name,
          Pointer<NativeType> data,
          Pointer<NativeType> pfnBeginThread,
          Pointer<NativeType> pfnEndThread,
        )
      >('SDL_CreateThreadRuntime');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = sdlCreateThreadRuntimeLookupFunction(
    fn,
    namePointer,
    data,
    pfnBeginThread,
    pfnEndThread,
  );
  calloc.free(namePointer);
  return result;
}