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.
0
votes
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.
aiocbhas alsoaio_sigeventfield, that you can use for the callback so no need for polling byaio_error. - j123b567aio_errorright afteraio_readthen there is clearly no point in using asynchronous io. Actually you should provide some example code for clarification. - user7860670