Bitcoin full node and query server

Jul 18, 2018

View in context in the libbitcoin Slack #general mirror.

N
narodnik07:19
Damn I should have been using weak_ptr all these years when writing callback code in libbitcoin:
void MyClass::startTimer()
{
    std::weak_ptr<MyClass> weak = shared_from_this();
    timer_.async_wait( [weak, this](const boost::system::error_code& ec)
    {
        auto self = weak.lock();
        if (self)
        {
            self->handleTimeout();
        }
        else
        {
            std::cout << "Target object no longer exists!\n";
        }
    } );
}
(edited)