[英]What's the difference between aio_read and read/EWOULDBLOCK?
In aio_read, we use aio_error function on a aiocb struct to check whether operation is finished. 在aio_read中,我们对aiocb结构使用aio_error函数来检查操作是否完成。 To me, it seems as polling and same as read followed by checking EWOULDBLOCK as a return value.
对我来说,它看起来像轮询并且与读取相同,然后将EWOULDBLOCK检查为返回值。
we use aio_error function on a aiocb struct to check whether operation is finished.
我们在aiocb结构上使用aio_error函数来检查操作是否完成。
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.
对我来说,它看起来像轮询并且与读取相同,然后将EWOULDBLOCK检查为返回值。
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.
EWOULDBLOCK表示操作已完成并且没有传输任何数据。
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. 使用异步I / O时,您当然不应该“轮询”:您应该只允许完成处理程序运行,并让其检查结果是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.