Linux 上的 Boost Asio 不使用 Epoll
我的印象是 boost::asio 默认情况下会使用 epoll 设置而不是 select 实现,但在运行一些测试后,看起来我的设置正在使用 select。
操作系统:RHEL 4
内核:2.6
GCC:3.4.6
我编写了一个小测试程序来验证正在使用哪个反应器标头,看起来它使用的是 select 反应器而不是 epoll 反应器。
#include <boost/asio.hpp>
#include <string>
#include <iostream>
std::string output;
#if defined(BOOST_ASIO_EPOLL_REACTOR_HPP)
int main(void)
{
std::cout << "you have epoll enabled." << std::endl;
}
#elif defined(BOOST_ASIO_DETAIL_SELECT_REACTOR_HPP)
int main(void)
{
std::cout << "you have select enabled." << std::endl;
}
#else
int main(void)
{
std::cout << "this shit is confusing." << std::endl;
}
#endif
我可能做错了什么?
I was under the impression that boost::asio would use an epoll setup by default instead of a select implementation, but after running some tests it looks like my setup is using select.
OS: RHEL 4
Kernel:2.6
GCC:3.4.6
I wrote a little test program to verify which reactor header was being used, and it looks like its using the select reactor rather than the epoll reactor.
#include <boost/asio.hpp>
#include <string>
#include <iostream>
std::string output;
#if defined(BOOST_ASIO_EPOLL_REACTOR_HPP)
int main(void)
{
std::cout << "you have epoll enabled." << std::endl;
}
#elif defined(BOOST_ASIO_DETAIL_SELECT_REACTOR_HPP)
int main(void)
{
std::cout << "you have select enabled." << std::endl;
}
#else
int main(void)
{
std::cout << "this shit is confusing." << std::endl;
}
#endif
What could I be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的程序也对我说“选择”,但 asio 正在使用 epoll_wait(),正如
ps -Teo tid,wchan:25,comm
报告的那样。怎么样
(从
/usr/include/boost/asio/serial_port_service.hpp
抓取 ifdefs 的阶梯)Your program says "select" for me too, yet asio is using epoll_wait(), as
ps -Teo tid,wchan:25,comm
reports.How about
(the ladder of ifdefs grabbed from
/usr/include/boost/asio/serial_port_service.hpp
)