SDL_WriteAsyncIO(3)
π« SDL_WriteAsyncIO β NAME π«
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one's called SDL_WriteAsyncIO and it's literally here to Start an async write. that's it, that's the whole vibe. β¨
π¦ SYNOPSIS π¦
#include <SDL3/SDL_asyncio.h>
bool SDL_WriteAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata);
look at her. six parameters. main character energy fr fr. π
πΈ DESCRIPTION πΈ
so what's actually happening here? this function writes size bytes, starting from the offset position in the data source, into the area pointed at by ptr. iconic. π
the whole point is that this function returns as quickly as possible β it does not sit around waiting for the write to finish. on a successful return, the work just keeps going in the background like it's got its own little life. and here's the twist that lowkey trips people up: if the work does begin, then even failure is asynchronous. a failing return value from this function only means the work couldn't start at all. periodt. π
β οΈ bestie listen. ptr must remain available until the work is done, and it may be accessed by the system at any time until then. Do not allocate it on the stack β this might take longer than the life of the calling function to complete! π that's a real "not me getting a dangling pointer" moment and we are NOT doing that.
an SDL_AsyncIOQueue must be specified β no queue, no service. the newly-created task gets added to it when it completes its work. π«Ά
π§ FUNCTION PARAMETERS π§
asyncioβ a pointer to anSDL_AsyncIOstructure. the source of truth, the data source in question.ptrβ a pointer to a buffer to write data from. (yes, from β keep it alive, see the warning above π«£)offsetβ the position to start writing to the data source.sizeβ the number of bytes to write to the data source.queueβ a queue to add the newSDL_AsyncIOto.userdataβ an app-defined pointer that will be provided with the task results. your little note-to-self that comes back to you later. π
β RETURN VALUE β
returns true on success or false on failure; call SDL_GetError() for more information. and remember the lore from above: a false here means the work couldn't start, not necessarily that the write failed. iykyk. π₯
π THREAD SAFETY π
It is safe to call this function from any thread. yes queen, any thread, go off. π
π AVAILABILITY π
This function is available since SDL 3.2.0. glow-up complete. β¨
π SEE ALSO π
and that's the whole page, bestie!! π brought to you by the lovely folks at Simple Directmedia Layer, this edition stamped SDL 3.4.18 β thanks for reading, mwah, slay, bye!! ππ¦π
π¦ 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