Boost logo

Boost Users :

From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2019-09-11 00:10:36


On Mon, Sep 9, 2019 at 11:10 PM Stephan Menzel via Boost-users
<boost-users_at_[hidden]> wrote:
> 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/b7230f12f16fe7a9f7a1ece5be1f607c8552448a/include/boost/beast/websocket/detail/service.ipp#L46>

Regards


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net