Updated: April 19, 2023 |
Wait for asynchronous I/O operations to be completed
#include <aio.h> int aio_suspend( const struct aiocb * const list[], int nent, const struct timespec * timeout );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The aio_suspend() function suspends the calling thread until at least one of the asynchronous I/O operations referenced by the list argument has been completed, until a signal interrupts the function, or, if timeout isn't NULL, until the time interval specified by timeout has passed.
If any of the aiocb structures in the list correspond to completed asynchronous I/O operations (i.e., the error status for the operation isn't EINPROGRESS) at the time of the call, aio_suspend() returns without suspending the calling thread.
0 if one or more of the asynchronous I/O operations have been completed, otherwise -1 (errno is set).
You can determine which asynchronous I/O operations were completed by scanning the associated error and return status, using aio_error() and aio_return().
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
The first time you call an aio_* function, a thread pool is created, making your process multithreaded if it isn't already. Because of this, after a fork() the child can not use any of the aio_*() functions if the parent used any aio_*() functions before the fork(). The thread pool isn't destroyed until your process ends.