SDL_WaitAsyncIOResult(3)
π SDL_WaitAsyncIOResult π
okay bestie, welcome to the SDL_WaitAsyncIOResult(3) page β this one lives in the SDL3 FUNCTIONS section of the manual and it's literally the "girl just go to sleep until the work is done" function πβ¨
β¨ NAME β¨
SDL_WaitAsyncIOResult β block until an async I/O task queue has a completed task. no cap, that's the whole job π
π SYNOPSIS π
#include <SDL3/SDL_asyncio.h>
bool SDL_WaitAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome, Sint32 timeoutMS);
π¦ DESCRIPTION π¦
so here's the vibe: this function puts the calling thread to sleep π΄ until there's a task assigned to the queue that has finished. that's it, that's the function.
if a task assigned to the queue has finished, it returns true and fills in outcome with the details of the task. if no task in the queue has finished, this function returns false. simple as π
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. so like, don't go touching that pointer after, bestie, it's gone π»
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. teamwork, but make it mutually exclusive π«Ά
β οΈ 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 β sotimeoutMSis a maximum wait time, and this function may returnfalsesooner. it's giving "false alarm, go back to bed" π
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. so false doesn't always mean timeout, iykyk π
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. obsessed with that pattern fr fr π
πΈ FUNCTION PARAMETERS πΈ
queueβ the async I/O task queue to wait on. the one we're stanning π―outcomeβ details of a finished task will be written here. May not beNULL. not me stressing this, it's literally in the docs πtimeoutMSβ the maximum time to wait, in milliseconds, or-1to wait indefinitely. the "how long am I willing to be patient" number β³
π RETURN VALUE π
returns true if task has completed, false otherwise. binary. iconic. periodt π
β THREAD SAFETY β
it is safe to call this function from any thread. every thread is the main character here, we don't gatekeep π
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on something older... bestie, update π
π₯ SEE ALSO π₯
SDL_SignalAsyncIOQueue(3)β the "wake up babe, new task dropped" bestie to this function π«Ά
and that's the page, my love π written for Simple Directmedia Layer, SDL 3.4.18 edition β go forth, wait on your queues responsibly, and remember: -1 means forever, and forever is a long time πβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms