sdlReadAsyncIo function

bool sdlReadAsyncIo(
  1. Pointer<SdlAsyncIo> asyncio,
  2. Pointer<NativeType> ptr,
  3. int offset,
  4. int size,
  5. Pointer<SdlAsyncIoQueue> queue,
  6. Pointer<NativeType> userdata,
)

Start an async read.

This function reads up to size bytes from offset position in the data source to the area pointed at by ptr. This function may read less bytes than requested.

This function returns as quickly as possible; it does not wait for the read to complete. On a successful return, this work will continue in the background. If the work begins, even failure is asynchronous: a failing return value from this function only means the work couldn't start at all.

ptr must remain available until the work is done, and may be accessed by the system at any time until then. Do not allocate it on the stack, as this might take longer than the life of the calling function to complete!

An SDL_AsyncIOQueue must be specified. The newly-created task will be added to it when it completes its work.

\param asyncio a pointer to an SDL_AsyncIO structure. \param ptr a pointer to a buffer to read data into. \param offset the position to start reading in the data source. \param size the number of bytes to read from the data source. \param queue a queue to add the new SDL_AsyncIO to. \param userdata an app-defined pointer that will be provided with the task results. \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_WriteAsyncIO \sa SDL_CreateAsyncIOQueue \sa SDL_GetAsyncIOTaskResult

extern SDL_DECLSPEC bool SDLCALL SDL_ReadAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata)

Implementation

bool sdlReadAsyncIo(
    Pointer<SdlAsyncIo> asyncio,
    Pointer<NativeType> ptr,
    int offset,
    int size,
    Pointer<SdlAsyncIoQueue> queue,
    Pointer<NativeType> userdata) {
  final sdlReadAsyncIoLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(
          Pointer<SdlAsyncIo> asyncio,
          Pointer<NativeType> ptr,
          Uint64 offset,
          Uint64 size,
          Pointer<SdlAsyncIoQueue> queue,
          Pointer<NativeType> userdata),
      int Function(
          Pointer<SdlAsyncIo> asyncio,
          Pointer<NativeType> ptr,
          int offset,
          int size,
          Pointer<SdlAsyncIoQueue> queue,
          Pointer<NativeType> userdata)>('SDL_ReadAsyncIO');
  return sdlReadAsyncIoLookupFunction(
          asyncio, ptr, offset, size, queue, userdata) ==
      1;
}