[MS] Making an agile version of a Windows Runtime delegate in C++/WinRT, part 10 - devamazonaws.blogspot.com
In part 5 of this unnecessarily long series on agile delegates , commenter LB asked , "Is the ContextCallback in the deleter guaranteed to always succeed? According to the docs it can fail. I wonder if there's a way to move the fallible part to an earlier point so the deleter can be infallible." Let's look at the first part: What if IContextCallback:: ContextCallback fails? If it fails, it means that COM couldn't switch to the destination context. If you can't switch to the destination context, then you can't release the pointer. It's not clear what recovery is possible anyway. Do you just keep retrying until it finally works? If the destination context is an ASTA, then it's possible that the reason is that the context is already busy, and ASTA doesn't allow re-entrancy. We'd have to wait a little bit and try again later, when the destination context might be ready. We can't just block on the retry because the destination con...