aio_suspend()

Ожидать завершения асинхронных операций ввода/вывода

Прототип:

#include <aio.h>
int aio_suspend( const struct aiocb *const list[],
int nent,
const struct timespec *timeout );

Аргументы:

list
A list of struct aiocb structures describing the asynchronous operations you want to wait for. Each struct aiocb must have been used in initiating an asynchronous I/O request via aio_read(), aio_write(), or lio_listio(). The list may contain NULL pointers, which aio_suspend() ignores.
nent
The number of entries in the list.
timeout
NULL, or a pointer to a struct timespec that specifies the maximum length of time you want to wait for.

Библиотека:

libc

Описание:

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 struct 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
Успешное завершение. Одна или несколько асинхронных операций были завершены.
-1
Возникла ошибка. Код ошибки записан в errno.

You can determine which asynchronous I/O operations were completed by scanning the associated error and return status, using aio_error() and aio_return().

Коды ошибок:

EAGAIN
No asynchronous I/O operation indicated in the list was completed in the time interval indicated by timeout.
EINTR
A signal interrupted the aio_suspend() function. Note that, since each asynchronous I/O operation may possibly provoke a signal when it's completed, this error return may be caused by the completion of one (or more) of the very I/O operations you're waiting on.

Классификация:

POSIX 1003.1 AIO

Точка остановки потока
Да
Обработчик прерываний
Нет
Обработчик сигналов
Да
В потоке
Да

Предостережения:

The first time you call an aio_*() function, a thread pool is created, making your process multithreaded if it isn't already. The thread pool isn't destroyed until your process ends.

Тематические ссылки:

aio_cancel(), aio_error(), aio_fsync(), aio_read(), aio_return(), aio_write(), struct aiocb, lio_listio(), struct timespec




Предыдущий раздел: Описание API системной библиотеки