Function SDL_ReadAsyncIO

pub unsafe extern "C" fn SDL_ReadAsyncIO(
    asyncio: *mut SDL_AsyncIO,
    ptr: *mut c_void,
    offset: u64,
    size: u64,
    queue: *mut SDL_AsyncIOQueue,
    userdata: *mut c_void,
) -> bool
Available on crate feature dep_sdl3 only.
Expand description

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.

§Parameters

  • asyncio: a pointer to an SDL_AsyncIO structure.
  • ptr: a pointer to a buffer to read data into.
  • offset: the position to start reading in the data source.
  • size: the number of bytes to read from the data source.
  • queue: a queue to add the new SDL_AsyncIO to.
  • userdata: an app-defined pointer that will be provided with the task results.

§Return value

Returns true on success or false on failure; call [SDL_GetError()] for more information.

§Thread safety

It is safe to call this function from any thread.

§Availability

This function is available since SDL 3.2.0.

§See also