On Mon, Sep 9, 2019 at 11:10 PM Stephan Menzel via Boost-users
I'm in the process of creating more such composed ops for ever recurring use cases and perhaps I find a way to tie this lambdas lifetime to the whole operation. As it happens, my gut felling tells me there are cases when the timer lambda will dangle around and potentially crash, perhaps when the op is used and the io_service being destroyed and not polled before destruction. I couldn't verify this in the unit test yet but there's often cases like this that go overlooked.
Yes, that can happen depending on your implementation. This is solved by tracking your objects in an execution_context::service and performing cleanup when the io_context is shut down, as beast::websocket::stream does: https://github.com/boostorg/beast/blob/b7230f12f16fe7a9f7a1ece5be1f607c85524... Regards