- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我io_service::run()
只在一个线程中运行,那么io_service::post()
调用是在我要求它们执行的顺序相同,或者它们可以按任意顺序执行,我仍然需要使用 strand
来强制序列化执行?
最佳答案
这个问题之前已经处理过,例如
写的很清楚
if any of the following conditions are true:
s.post(a)
happens-befores.post(b)
- ...
then
asio_handler_invoke(a1, &a1)
happens-beforeasio_handler_invoke(b1, &b1)
.
请注意,单个 IO 线程会创建隐式链(文档)
注意 关于另一个答案:当处理程序调用在异步操作完成时隐式完成时,当然这不成立。
Note that in the following case:
async_op_1(..., s.wrap(a));
async_op_2(..., s.wrap(b));the completion of the first async operation will perform
s.dispatch(a)
, and the second will performs.dispatch(b)
, but the order in which those are performed is unspecified. That is, you cannot state whether one happens-before the other. Therefore none of the above conditions are met and no ordering guarantee is made.
关于c++ - 使用仅在单个线程中调用的 io_service::run() 序列化 io_service::post() 执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31527192/
我是一名优秀的程序员,十分优秀!