0
votes

In aio_read, we use aio_error function on a aiocb struct to check whether operation is finished. To me, it seems as polling and same as read followed by checking EWOULDBLOCK as a return value.

1
aiocb has also aio_sigevent field, that you can use for the callback so no need for polling by aio_error. - j123b567
If you are calling aio_error right after aio_read then there is clearly no point in using asynchronous io. Actually you should provide some example code for clarification. - user7860670

1 Answers

2
votes

we use aio_error function on a aiocb struct to check whether operation is finished.

No we don't. We use it to check whether it finished with an error.

To me, it seems as polling and same as read followed by checking EWOULDBLOCK as a return value.

No. If the operation hasn't finished, with or without an error, it continues, asynchronously. EWOULDBLOCK means the operation has finished and without transferring any data.

You should certainly not 'poll' when using async I/O: you should just allow the completion handler to run and have it check what the result was.