What's the difference between boost::io_service poll_one and run_one?

我只是一个虾纸丫 提交于 2019-11-27 05:52:34

问题


io_service::poll_one Run the io_service object's event processing loop to execute one ready handler.

vs

io_service::run_one Run the io_service object's event processing loop to execute at most one handler.

From that explanation it would seem poll_one could execute more than one handler? Does run_one or poll_one use any thread that's called run() or only the thread that calls poll_one/run_one?

The documentation for ASIO is very sparse.


回答1:


poll_one will return immediately (non-blocking) in case there is no event to process.

run_one will block the calling thread until one event is ready to process.

You could also check some documentation here



来源:https://stackoverflow.com/questions/8727568/whats-the-difference-between-boostio-service-poll-one-and-run-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!