asio boost 异步错误处理_c – boost :: asio异步处理程序在取消后无错误地调用

好的,答案是:

>不,我不能仅仅依赖于operation_aborted错误.

>当然,这不是Asio的一个错误,只是缺乏经验.

>有一些官方documentation.它是定时器,而不是插座,但同样的原则适用:

如果在调用cancel()时计时器已经过期,则异步等待操作的处理程序将:

>已被调用;要么

>已经在不久的将来排队等待调用.

基本上,我错误地假设如果我为io_service使用单个线程,那么在执行某些处理程序时将阻止每个操作.

我报告的行为实际上很有意义,似乎每个使用Asio的人都知道这一点.我已经梳理了Asio的邮件列表,并在here,here,here和here这个主题上找到了很多讨论.

For instance, a write operation may complete successfully while you are inside a handler but before you have got around to calling socket cancel, causing its completion handler to be posted to the queue. As I understand it, the error code is determined by the status of the operation that completed, not the state of the socket at the time the handler is picked off the queue and executed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值