SDL_asyncio.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /* WIKI CATEGORY: AsyncIO */
  19. /**
  20. * # CategoryAsyncIO
  21. *
  22. * SDL offers a way to perform I/O asynchronously. This allows an app to read
  23. * or write files without waiting for data to actually transfer; the functions
  24. * that request I/O never block while the request is fulfilled.
  25. *
  26. * Instead, the data moves in the background and the app can check for results
  27. * at their leisure.
  28. *
  29. * This is more complicated than just reading and writing files in a
  30. * synchronous way, but it can allow for more efficiency, and never having
  31. * framerate drops as the hard drive catches up, etc.
  32. *
  33. * The general usage pattern for async I/O is:
  34. *
  35. * - Create one or more SDL_AsyncIOQueue objects.
  36. * - Open files with SDL_AsyncIOFromFile.
  37. * - Start I/O tasks to the files with SDL_ReadAsyncIO or SDL_WriteAsyncIO,
  38. * putting those tasks into one of the queues.
  39. * - Later on, use SDL_GetAsyncIOResult on a queue to see if any task is
  40. * finished without blocking. Tasks might finish in any order with success
  41. * or failure.
  42. * - When all your tasks are done, close the file with SDL_CloseAsyncIO. This
  43. * also generates a task, since it might flush data to disk!
  44. *
  45. * This all works, without blocking, in a single thread, but one can also wait
  46. * on a queue in a background thread, sleeping until new results have arrived:
  47. *
  48. * - Call SDL_WaitAsyncIOResult from one or more threads to efficiently block
  49. * until new tasks complete.
  50. * - When shutting down, call SDL_SignalAsyncIOQueue to unblock any sleeping
  51. * threads despite there being no new tasks completed.
  52. *
  53. * And, of course, to match the synchronous SDL_LoadFile, we offer
  54. * SDL_LoadFileAsync as a convenience function. This will handle allocating a
  55. * buffer, slurping in the file data, and null-terminating it; you still check
  56. * for results later.
  57. *
  58. * Behind the scenes, SDL will use newer, efficient APIs on platforms that
  59. * support them: Linux's io_uring and Windows 11's IoRing, for example. If
  60. * those technologies aren't available, SDL will offload the work to a thread
  61. * pool that will manage otherwise-synchronous loads without blocking the app.
  62. *
  63. * ## Best Practices
  64. *
  65. * Simple non-blocking i/o--for an app that just wants to pick up data
  66. * whenever it's ready without losing framerate waiting on disks to spin--can
  67. * use whatever pattern works well for the program. In this case, simply call
  68. * SDL_ReadAsyncIO, or maybe SDL_LoadFileAsync, as needed. Once a frame, call
  69. * SDL_GetAsyncIOResult to check for any completed tasks and deal with the
  70. * data as it arrives.
  71. *
  72. * If two separate pieces of the same program need their own i/o, it is legal
  73. * for each to create their own queue. This will prevent either piece from
  74. * accidentally consuming the other's completed tasks. Each queue does require
  75. * some amount of resources, but it is not an overwhelming cost. Do not make a
  76. * queue for each task, however. It is better to put many tasks into a single
  77. * queue. They will be reported in order of completion, not in the order they
  78. * were submitted, so it doesn't generally matter what order tasks are started.
  79. *
  80. * One async i/o queue can be shared by multiple threads, or one thread can
  81. * have more than one queue, but the most efficient way--if ruthless
  82. * efficiency is the goal--is to have one queue per thread, with multiple
  83. * threads working in parallel, and attempt to keep each queue loaded with
  84. * tasks that are both started by and consumed by the same thread. On modern
  85. * platforms that can use newer interfaces, this can keep data flowing as
  86. * efficiently as possible all the way from storage hardware to the app, with
  87. * no contention between threads for access to the same queue.
  88. *
  89. * Written data is not guaranteed to make it to physical media by the time a
  90. * closing task is completed, unless SDL_CloseAsyncIO is called with its
  91. * `flush` parameter set to true, which is to say that a successful result
  92. * here can still result in lost data during an unfortunately-timed power
  93. * outage if not flushed. However, flushing will take longer and may be
  94. * unnecessary, depending on the app's needs.
  95. */
  96. #ifndef SDL_asyncio_h_
  97. #define SDL_asyncio_h_
  98. #include <SDL3/SDL_stdinc.h>
  99. #include <SDL3/SDL_begin_code.h>
  100. /* Set up for C function definitions, even when using C++ */
  101. #ifdef __cplusplus
  102. extern "C" {
  103. #endif
  104. /**
  105. * The asynchronous I/O operation structure.
  106. *
  107. * This operates as an opaque handle. One can then request read or write
  108. * operations on it.
  109. *
  110. * \since This struct is available since SDL 3.0.0.
  111. *
  112. * \sa SDL_AsyncIOFromFile
  113. */
  114. typedef struct SDL_AsyncIO SDL_AsyncIO;
  115. /**
  116. * Types of asynchronous I/O tasks.
  117. *
  118. * \since This enum is available since SDL 3.0.0.
  119. */
  120. typedef enum SDL_AsyncIOTaskType
  121. {
  122. SDL_ASYNCIO_TASK_READ, /**< A read operation. */
  123. SDL_ASYNCIO_TASK_WRITE, /**< A write operation. */
  124. SDL_ASYNCIO_TASK_CLOSE /**< A close operation. */
  125. } SDL_AsyncIOTaskType;
  126. /**
  127. * Possible outcomes of an asynchronous I/O task.
  128. *
  129. * \since This enum is available since SDL 3.0.0.
  130. */
  131. typedef enum SDL_AsyncIOResult
  132. {
  133. SDL_ASYNCIO_COMPLETE, /**< request was completed without error */
  134. SDL_ASYNCIO_FAILURE, /**< request failed for some reason; check SDL_GetError()! */
  135. SDL_ASYNCIO_CANCELLED /**< request was cancelled before completing. */
  136. } SDL_AsyncIOResult;
  137. /**
  138. * Information about a completed asynchronous I/O request.
  139. *
  140. * \since This struct is available since SDL 3.0.0.
  141. */
  142. typedef struct SDL_AsyncIOOutcome
  143. {
  144. SDL_AsyncIO *asyncio; /**< what generated this task. This pointer will be invalid if it was closed! */
  145. SDL_AsyncIOTaskType type; /**< What sort of task was this? Read, write, etc? */
  146. SDL_AsyncIOResult result; /**< the result of the work (success, failure, cancellation). */
  147. void *buffer; /**< buffer where data was read/written. */
  148. Uint64 offset; /**< offset in the SDL_AsyncIO where data was read/written. */
  149. Uint64 bytes_requested; /**< number of bytes the task was to read/write. */
  150. Uint64 bytes_transferred; /**< actual number of bytes that were read/written. */
  151. void *userdata; /**< pointer provided by the app when starting the task */
  152. } SDL_AsyncIOOutcome;
  153. /**
  154. * A queue of completed asynchronous I/O tasks.
  155. *
  156. * When starting an asynchronous operation, you specify a queue for the new
  157. * task. A queue can be asked later if any tasks in it have completed,
  158. * allowing an app to manage multiple pending tasks in one place, in whatever
  159. * order they complete.
  160. *
  161. * \since This struct is available since SDL 3.0.0.
  162. *
  163. * \sa SDL_CreateAsyncIOQueue
  164. * \sa SDL_ReadAsyncIO
  165. * \sa SDL_WriteAsyncIO
  166. * \sa SDL_GetAsyncIOResult
  167. * \sa SDL_WaitAsyncIOResult
  168. */
  169. typedef struct SDL_AsyncIOQueue SDL_AsyncIOQueue;
  170. /**
  171. * Use this function to create a new SDL_AsyncIO object for reading from
  172. * and/or writing to a named file.
  173. *
  174. * The `mode` string understands the following values:
  175. *
  176. * - "r": Open a file for reading only. It must exist.
  177. * - "w": Open a file for writing only. It will create missing files or
  178. * truncate existing ones.
  179. * - "r+": Open a file for update both reading and writing. The file must
  180. * exist.
  181. * - "w+": Create an empty file for both reading and writing. If a file with
  182. * the same name already exists its content is erased and the file is
  183. * treated as a new empty file.
  184. *
  185. * There is no "b" mode, as there is only "binary" style I/O, and no "a" mode
  186. * for appending, since you specify the position when starting a task.
  187. *
  188. * This function supports Unicode filenames, but they must be encoded in UTF-8
  189. * format, regardless of the underlying operating system.
  190. *
  191. * This call is _not_ asynchronous; it will open the file before returning,
  192. * under the assumption that doing so is generally a fast operation. Future
  193. * reads and writes to the opened file will be async, however.
  194. *
  195. * \param file a UTF-8 string representing the filename to open.
  196. * \param mode an ASCII string representing the mode to be used for opening
  197. * the file.
  198. * \returns a pointer to the SDL_AsyncIO structure that is created or NULL on
  199. * failure; call SDL_GetError() for more information.
  200. *
  201. * \since This function is available since SDL 3.2.0.
  202. *
  203. * \sa SDL_CloseAsyncIO
  204. * \sa SDL_ReadAsyncIO
  205. * \sa SDL_WriteAsyncIO
  206. */
  207. extern SDL_DECLSPEC SDL_AsyncIO * SDLCALL SDL_AsyncIOFromFile(const char *file, const char *mode);
  208. /**
  209. * Use this function to get the size of the data stream in an SDL_AsyncIO.
  210. *
  211. * This call is _not_ asynchronous; it assumes that obtaining this info is a
  212. * non-blocking operation in most reasonable cases.
  213. *
  214. * \param asyncio the SDL_AsyncIO to get the size of the data stream from.
  215. * \returns the size of the data stream in the SDL_IOStream on success or a
  216. * negative error code on failure; call SDL_GetError() for more
  217. * information.
  218. *
  219. * \threadsafety It is safe to call this function from any thread.
  220. *
  221. * \since This function is available since SDL 3.2.0.
  222. */
  223. extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetAsyncIOSize(SDL_AsyncIO *asyncio);
  224. /**
  225. * Start an async read.
  226. *
  227. * This function reads up to `size` bytes from `offset` position in the data
  228. * source to the area pointed at by `ptr`. This function may read less bytes
  229. * than requested.
  230. *
  231. * This function returns as quickly as possible; it does not wait for the read
  232. * to complete. On a successful return, this work will continue in the
  233. * background. If the work begins, even failure is asynchronous: a failing
  234. * return value from this function only means the work couldn't start at all.
  235. *
  236. * `ptr` must remain available until the work is done, and may be accessed by
  237. * the system at any time until then. Do not allocate it on the stack, as this
  238. * might take longer than the life of the calling function to complete!
  239. *
  240. * An SDL_AsyncIOQueue must be specified. The newly-created task will be added
  241. * to it when it completes its work.
  242. *
  243. * \param asyncio a pointer to an SDL_AsyncIO structure.
  244. * \param ptr a pointer to a buffer to read data into.
  245. * \param offset the position to start reading in the data source.
  246. * \param size the number of bytes to read from the data source.
  247. * \param queue a queue to add the new SDL_AsyncIO to.
  248. * \param userdata an app-defined pointer that will be provided with the task
  249. * results.
  250. * \returns true on success or false on failure; call SDL_GetError() for more
  251. * information.
  252. *
  253. * \threadsafety It is safe to call this function from any thread.
  254. *
  255. * \since This function is available since SDL 3.2.0.
  256. *
  257. * \sa SDL_WriteAsyncIO
  258. * \sa SDL_CreateAsyncIOQueue
  259. * \sa SDL_GetAsyncIOTaskResult
  260. */
  261. extern SDL_DECLSPEC bool SDLCALL SDL_ReadAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata);
  262. /**
  263. * Start an async write.
  264. *
  265. * This function writes `size` bytes from `offset` position in the data source
  266. * to the area pointed at by `ptr`.
  267. *
  268. * This function returns as quickly as possible; it does not wait for the
  269. * write to complete. On a successful return, this work will continue in the
  270. * background. If the work begins, even failure is asynchronous: a failing
  271. * return value from this function only means the work couldn't start at all.
  272. *
  273. * `ptr` must remain available until the work is done, and may be accessed by
  274. * the system at any time until then. Do not allocate it on the stack, as this
  275. * might take longer than the life of the calling function to complete!
  276. *
  277. * An SDL_AsyncIOQueue must be specified. The newly-created task will be added
  278. * to it when it completes its work.
  279. *
  280. * \param asyncio a pointer to an SDL_AsyncIO structure.
  281. * \param ptr a pointer to a buffer to write data from.
  282. * \param offset the position to start writing to the data source.
  283. * \param size the number of bytes to write to the data source.
  284. * \param queue a queue to add the new SDL_AsyncIO to.
  285. * \param userdata an app-defined pointer that will be provided with the task
  286. * results.
  287. * \returns true on success or false on failure; call SDL_GetError() for more
  288. * information.
  289. *
  290. * \threadsafety It is safe to call this function from any thread.
  291. *
  292. * \since This function is available since SDL 3.2.0.
  293. *
  294. * \sa SDL_ReadAsyncIO
  295. * \sa SDL_CreateAsyncIOQueue
  296. * \sa SDL_GetAsyncIOTaskResult
  297. */
  298. extern SDL_DECLSPEC bool SDLCALL SDL_WriteAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata);
  299. /**
  300. * Close and free any allocated resources for an async I/O object.
  301. *
  302. * Closing a file is _also_ an asynchronous task! If a write failure were to
  303. * happen during the closing process, for example, the task results will
  304. * report it as usual.
  305. *
  306. * Closing a file that has been written to does not guarantee the data has
  307. * made it to physical media; it may remain in the operating system's file
  308. * cache, for later writing to disk. This means that a successfully-closed
  309. * file can be lost if the system crashes or loses power in this small window.
  310. * To prevent this, call this function with the `flush` parameter set to true.
  311. * This will make the operation take longer, and perhaps increase system load
  312. * in general, but a successful result guarantees that the data has made it to
  313. * physical storage. Don't use this for temporary files, caches, and
  314. * unimportant data, and definitely use it for crucial irreplaceable files,
  315. * like game saves.
  316. *
  317. * This function guarantees that the close will happen after any other pending
  318. * tasks to `asyncio`, so it's safe to open a file, start several operations,
  319. * close the file immediately, then check for all results later. This function
  320. * will not block until the tasks have completed.
  321. *
  322. * Once this function returns non-NULL, `asyncio` is no longer valid,
  323. * regardless of any future outcomes. Any completed tasks might still contain
  324. * this pointer in their SDL_AsyncIOOutcome data, in case the app was using
  325. * this value to track information, but it should not be used again.
  326. *
  327. * If this function returns false, the close wasn't started at all, and it's
  328. * safe to attempt to close again later.
  329. *
  330. * An SDL_AsyncIOQueue must be specified. The newly-created task will be added
  331. * to it when it completes its work.
  332. *
  333. * \param asyncio a pointer to an SDL_AsyncIO structure to close.
  334. * \param flush true if data should sync to disk before the task completes.
  335. * \param queue a queue to add the new SDL_AsyncIO to.
  336. * \param userdata an app-defined pointer that will be provided with the task
  337. * results.
  338. * \returns true on success or false on failure; call SDL_GetError() for more
  339. * information.
  340. *
  341. * \threadsafety It is safe to call this function from any thread, but two
  342. * threads should not attempt to close the same object.
  343. *
  344. * \since This function is available since SDL 3.2.0.
  345. */
  346. extern SDL_DECLSPEC bool SDLCALL SDL_CloseAsyncIO(SDL_AsyncIO *asyncio, bool flush, SDL_AsyncIOQueue *queue, void *userdata);
  347. /**
  348. * Create a task queue for tracking multiple I/O operations.
  349. *
  350. * Async I/O operations are assigned to a queue when started. The queue can be
  351. * checked for completed tasks thereafter.
  352. *
  353. * \returns a new task queue object or NULL if there was an error; call
  354. * SDL_GetError() for more information.
  355. *
  356. * \threadsafety It is safe to call this function from any thread.
  357. *
  358. * \since This function is available since SDL 3.2.0.
  359. *
  360. * \sa SDL_DestroyAsyncIOQueue
  361. * \sa SDL_GetAsyncIOResult
  362. * \sa SDL_WaitAsyncIOResult
  363. */
  364. extern SDL_DECLSPEC SDL_AsyncIOQueue * SDLCALL SDL_CreateAsyncIOQueue(void);
  365. /**
  366. * Destroy a previously-created async I/O task queue.
  367. *
  368. * If there are still tasks pending for this queue, this call will block until
  369. * those tasks are finished. All those tasks will be deallocated. Their
  370. * results will be lost to the app.
  371. *
  372. * Any pending reads from SDL_LoadFileAsync() that are still in this queue
  373. * will have their buffers deallocated by this function, to prevent a memory
  374. * leak.
  375. *
  376. * Once this function is called, the queue is no longer valid and should not
  377. * be used, including by other threads that might access it while destruction
  378. * is blocking on pending tasks.
  379. *
  380. * Do not destroy a queue that still has threads waiting on it through
  381. * SDL_WaitAsyncIOResult(). You can call SDL_SignalAsyncIOQueue() first to
  382. * unblock those threads, and take measures (such as SDL_WaitThread()) to make
  383. * sure they have finished their wait and won't wait on the queue again.
  384. *
  385. * \param queue the task queue to destroy.
  386. *
  387. * \threadsafety It is safe to call this function from any thread, so long as
  388. * no other thread is waiting on the queue with
  389. * SDL_WaitAsyncIOResult.
  390. *
  391. * \since This function is available since SDL 3.2.0.
  392. */
  393. extern SDL_DECLSPEC void SDLCALL SDL_DestroyAsyncIOQueue(SDL_AsyncIOQueue *queue);
  394. /**
  395. * Query an async I/O task queue for completed tasks.
  396. *
  397. * If a task assigned to this queue has finished, this will return true and
  398. * fill in `outcome` with the details of the task. If no task in the queue has
  399. * finished, this function will return false. This function does not block.
  400. *
  401. * If a task has completed, this function will free its resources and the task
  402. * pointer will no longer be valid. The task will be removed from the queue.
  403. *
  404. * It is safe for multiple threads to call this function on the same queue at
  405. * once; a completed task will only go to one of the threads.
  406. *
  407. * \param queue the async I/O task queue to query.
  408. * \param outcome details of a finished task will be written here. May not be
  409. * NULL.
  410. * \returns true if task has completed, false otherwise.
  411. *
  412. * \threadsafety It is safe to call this function from any thread.
  413. *
  414. * \since This function is available since SDL 3.2.0.
  415. *
  416. * \sa SDL_WaitAsyncIOResult
  417. */
  418. extern SDL_DECLSPEC bool SDLCALL SDL_GetAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome);
  419. /**
  420. * Block until an async I/O task queue has a completed task.
  421. *
  422. * This function puts the calling thread to sleep until there a task assigned
  423. * to the queue that has finished.
  424. *
  425. * If a task assigned to the queue has finished, this will return true and
  426. * fill in `outcome` with the details of the task. If no task in the queue has
  427. * finished, this function will return false.
  428. *
  429. * If a task has completed, this function will free its resources and the task
  430. * pointer will no longer be valid. The task will be removed from the queue.
  431. *
  432. * It is safe for multiple threads to call this function on the same queue at
  433. * once; a completed task will only go to one of the threads.
  434. *
  435. * Note that by the nature of various platforms, more than one waiting thread
  436. * may wake to handle a single task, but only one will obtain it, so
  437. * `timeoutMS` is a _maximum_ wait time, and this function may return false
  438. * sooner.
  439. *
  440. * This function may return false if there was a system error, the OS
  441. * inadvertently awoke multiple threads, or if SDL_SignalAsyncIOQueue() was
  442. * called to wake up all waiting threads without a finished task.
  443. *
  444. * A timeout can be used to specify a maximum wait time, but rather than
  445. * polling, it is possible to have a timeout of -1 to wait forever, and use
  446. * SDL_SignalAsyncIOQueue() to wake up the waiting threads later.
  447. *
  448. * \param queue the async I/O task queue to wait on.
  449. * \param outcome details of a finished task will be written here. May not be
  450. * NULL.
  451. * \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait
  452. * indefinitely.
  453. * \returns true if task has completed, false otherwise.
  454. *
  455. * \threadsafety It is safe to call this function from any thread.
  456. *
  457. * \since This function is available since SDL 3.2.0.
  458. *
  459. * \sa SDL_SignalAsyncIOQueue
  460. */
  461. extern SDL_DECLSPEC bool SDLCALL SDL_WaitAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome, Sint32 timeoutMS);
  462. /**
  463. * Wake up any threads that are blocking in SDL_WaitAsyncIOResult().
  464. *
  465. * This will unblock any threads that are sleeping in a call to
  466. * SDL_WaitAsyncIOResult for the specified queue, and cause them to return
  467. * from that function.
  468. *
  469. * This can be useful when destroying a queue to make sure nothing is touching
  470. * it indefinitely. In this case, once this call completes, the caller should
  471. * take measures to make sure any previously-blocked threads have returned
  472. * from their wait and will not touch the queue again (perhaps by setting a
  473. * flag to tell the threads to terminate and then using SDL_WaitThread() to
  474. * make sure they've done so).
  475. *
  476. * \param queue the async I/O task queue to signal.
  477. *
  478. * \threadsafety It is safe to call this function from any thread.
  479. *
  480. * \since This function is available since SDL 3.2.0.
  481. *
  482. * \sa SDL_WaitAsyncIOResult
  483. */
  484. extern SDL_DECLSPEC void SDLCALL SDL_SignalAsyncIOQueue(SDL_AsyncIOQueue *queue);
  485. /**
  486. * Load all the data from a file path, asynchronously.
  487. *
  488. * This function returns as quickly as possible; it does not wait for the read
  489. * to complete. On a successful return, this work will continue in the
  490. * background. If the work begins, even failure is asynchronous: a failing
  491. * return value from this function only means the work couldn't start at all.
  492. *
  493. * The data is allocated with a zero byte at the end (null terminated) for
  494. * convenience. This extra byte is not included in SDL_AsyncIOOutcome's
  495. * bytes_transferred value.
  496. *
  497. * This function will allocate the buffer to contain the file. It must be
  498. * deallocated by calling SDL_free() on SDL_AsyncIOOutcome's buffer field
  499. * after completion.
  500. *
  501. * An SDL_AsyncIOQueue must be specified. The newly-created task will be added
  502. * to it when it completes its work.
  503. *
  504. * \param file the path to read all available data from.
  505. * \param queue a queue to add the new SDL_AsyncIO to.
  506. * \param userdata an app-defined pointer that will be provided with the task
  507. * results.
  508. * \returns true on success or false on failure; call SDL_GetError() for more
  509. * information.
  510. *
  511. * \since This function is available since SDL 3.2.0.
  512. *
  513. * \sa SDL_LoadFile_IO
  514. */
  515. extern SDL_DECLSPEC bool SDLCALL SDL_LoadFileAsync(const char *file, SDL_AsyncIOQueue *queue, void *userdata);
  516. /* Ends C function definitions when using C++ */
  517. #ifdef __cplusplus
  518. }
  519. #endif
  520. #include <SDL3/SDL_close_code.h>
  521. #endif /* SDL_asyncio_h_ */