Scroll to navigation

SDL_WaitAsyncIOResult(3) SDL3 FUNCTIONS SDL_WaitAsyncIOResult(3)

NAME

SDL_WaitAsyncIOResult - Block until an async I/O task queue has a completed task.

HEADER FILE

Defined in SDL3/SDL_asyncio.h

SYNOPSIS

#include "SDL3/SDL.h"
bool SDL_WaitAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome, Sint32 timeoutMS);

DESCRIPTION

This function puts the calling thread to sleep until there a task assigned to the queue that has finished.

If a task assigned to the queue has finished, this will return true and fill in outcome with the details of the task. If no task in the queue has finished, this function will return false.

If a task has completed, this function will free its resources and the task pointer will no longer be valid. The task will be removed from the queue.

It is safe for multiple threads to call this function on the same queue at once; a completed task will only go to one of the threads.

Note that by the nature of various platforms, more than one waiting thread may wake to handle a single task, but only one will obtain it, so timeoutMS is a _maximum_ wait time, and this function may return false sooner.

This function may return false if there was a system error, the OS inadvertently awoke multiple threads, or if

SDL_SignalAsyncIOQueue () was called to wake up all waiting threads without a finished task.

A timeout can be used to specify a maximum wait time, but rather than polling, it is possible to have a timeout of -1 to wait forever, and use

SDL_SignalAsyncIOQueue () to wake up the waiting threads later.

FUNCTION PARAMETERS

the async I/O task queue to wait on.
details of a finished task will be written here. May not be NULL.
the maximum time to wait, in milliseconds, or -1 to wait indefinitely.

RETURN VALUE

Returns true if task has completed, false otherwise.

THREAD SAFETY

It is safe to call this function from any thread.

AVAILABILITY

This function is available since SDL 3.2.0.

SEE ALSO

(3), SDL_SignalAsyncIOQueue(3)

SDL 3.2.4 Simple Directmedia Layer