简体   繁体   English

aio_read和read / EWOULDBLOCK有什么区别?

[英]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.

相关问题 aio.h aio_read()并写入内存泄漏 - aio.h aio_read() and write memory leak 来自 STDIN_FILENO 的 aio_read 在 OS X 中返回 EAGAIN - aio_read from STDIN_FILENO returns EAGAIN in OS X read()和getc()有什么区别 - What's the difference between read() and getc() read,readsome,get和getline之间有什么区别? - What's the difference between read, readsome, get, and getline? 读+写和读+写+截断有什么区别? - What is the difference between read+write and read+write+truncate? C ++ ifstream,ofstream:原始read()/ write()调用和二进制模式下的打开文件有什么区别? - C++ ifstream, ofstream: What's the difference between raw read()/write() calls and opening file in binary mode? 输入迭代器和只读前向迭代器之间有什么区别? - What's the difference between input iterators and read-only forward iterators? asio::tcp::socket 的 async_read_some 和 async_receive 有什么区别? - What is the difference between asio::tcp::socket's async_read_some and async_receive? 阻塞和非阻塞读取有什么区别? - What is the difference between a blocking and non-blocking read? 使用>> operator读取文件和读取具有读取功能的文件有什么区别? - What is the difference between reading a file with >> operator and reading a file with read function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM