|
Boost Users : |
Subject: Re: [Boost-users] boost::asio destructor segfault?
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-03-19 10:45:57
Sean McAllister wrote:
> The only functions I'm binding with boost::bind are members of
> ClassifierContext, eg:
>
> ICMessage::async_read(socket_,
>
boost::bind(&ClassifierContext::handleCmdMsg,
> this,
> _1,_2,_3));
>
> Since the io_service object is stopped in the destructor of
> ClassifierContext, shouldn't that be OK? Or should
> I still try to create a shared_from_this off of the ClassifierContext
> class?
>
Not sure, given you are running multiple threads. According to the
documentation, io_service::stop() doesn't block, so it could still be
needing the shared_from_this stuff.
Another approach is to allocate the work object in your member io_loop of
ClassifierContext, and in the destructor, do something like
m_work_ptr.reset();
ioService_.run();
this makes sure all outstanding operations are finished.
Cheers,
Rutger
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