Open Shangwei1024 opened 6 months ago
When calling cycletimer.cancel(ec) your completion handler (on_message) will be called with an error. Since you dont handle this error, you start the timer again which queues the completion handler again with its own copy of f.
When handling the error, f.use_count() is 1.
void on_message(const boost::system::error_code &_error) {
if (_error) return;
auto p = shared_from_this();
start_timer();
std::cout << __func__ << " " << p.use_count() << std::endl;
}
boost version is 1.72 I don`t understand why the finally f.use_count() is 2. I guess that the registered function for async_wait includes std::shared_ptr.