该属性可以这样描述:如果该操作被取消,则它的处理程序保证在执行时出现错误。
例如,boost::asio::deadline_timer没有该属性,如deadline_timer::cancel function 文档的备注部分所述。因此,即使取消计时器上的等待操作,它的回调也有可能在没有错误的情况下执行。
另一方面,该属性适用于 asio 套接字(至少我希望如此 :),因为文档中没有这样的评论)。
编辑:一个伪代码演示了截止时间计时器中缺少此属性:
1# User calls timer.async_wait with a handler H which is to be
executed when the action finishes.
2# Time passes.
3# Timeout has been reached, asio internally inserts the handler H into
a queue for later execution, but with error code indicating success.
User is unaware of when this step takes place.
4# User calls cancel on the timer, thus would expect the handler to be
executed with an error code indicating failure.
5# Asio takes the handler H from the queue and executes it with error
code indicating success as set in the step #3.
只需在步骤 #4 中设置一个布尔标志,然后在步骤 #5 中检查它,就可以轻松解决此问题,所以这不是问题。