[英]Boost Asio On Linux Not Using Epoll
我的印象是boost :: asio默認使用epoll設置而不是select實現,但是在運行一些測試之后看起來我的設置是使用select。
操作系統:RHEL 4
內核:2.6
GCC:3.4.6
我寫了一個小測試程序,以驗證正在使用哪個反應器頭,看起來它使用選擇反應器而不是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
我能做錯什么?
你的程序也為我說“選擇”,但asio正在使用epoll_wait(),如ps -Teo tid,wchan:25,comm
報告。
怎么樣
#include <iostream>
#include <string>
#include <boost/asio.hpp>
int main()
{
std::string output;
#if defined(BOOST_ASIO_HAS_IOCP)
output = "iocp" ;
#elif defined(BOOST_ASIO_HAS_EPOLL)
output = "epoll" ;
#elif defined(BOOST_ASIO_HAS_KQUEUE)
output = "kqueue" ;
#elif defined(BOOST_ASIO_HAS_DEV_POLL)
output = "/dev/poll" ;
#else
output = "select" ;
#endif
std::cout << output << std::endl;
}
(從/usr/include/boost/asio/serial_port_service.hpp
抓取ifdefs的梯子)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.