What#39;s the difference between boost::io_service poll_one and run_one?(boost::io_service poll_one 和 run_one 有什么区别?)
问题描述
io_service::poll_one 运行 io_service 对象的事件处理循环执行一个就绪处理程序.
io_service::poll_one Run the io_service object's event processing loop to execute one ready handler.
对比
io_service::run_one 运行 io_service 对象的事件处理循环最多执行一个处理程序.
io_service::run_one Run the io_service object's event processing loop to execute at most one handler.
从那个解释看来, poll_one 可以执行多个处理程序?run_one 或 poll_one 是使用任何名为 run() 的线程还是仅使用调用 poll_one/run_one 的线程?
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?
ASIO 的文档非常稀少.
The documentation for ASIO is very sparse.
推荐答案
poll_one 将立即返回(非阻塞),以防没有事件要处理.
poll_one will return immediately (non-blocking) in case there is no event to process.
run_one 将阻塞调用线程,直到一个事件准备好处理.
run_one will block the calling thread until one event is ready to process.
您还可以查看一些文档这里
这篇关于boost::io_service poll_one 和 run_one 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:boost::io_service poll_one 和 run_one 有什么区别?
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
