After reading these...
Cancelling boost asio deadline timer safely
Atomically cancel asio asynchronious timer from another thread
...I'd like to try and get clarification on an aspect of usage.
Per the first referenced question, cancelling a timer after it has expired but before its handler has run doesn't work. The handler for such an "in-flight" timer still runs normally.
This brings up a lifecycle question... A common usage pattern is for a timer to be a member of a class, and for its expiration handler to reference that parent class. The parent class can cancel the timer from its destructor, but there would seem to be a crash exposure under the scenario above since both the timer and parent class no longer exist when the handler runs.
If this is indeed the case, how can it be resolved? We could capture a std::weak_ptr to the parent class in the handler and check it before proceeding, but not every parent class may have its life-cycle managed via std::shared_ptr.