|
Boost Users : |
Subject: Re: [Boost-users] boost::asio destructor segfault?
From: Sean McAllister (smcallis_at_[hidden])
Date: 2010-03-19 10:54:37
On Fri, Mar 19, 2010 at 7:45 AM, Rutger ter Borg <rutger_at_[hidden]> wrote:
> 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
>
>
>
Hmmm, I've only got the one extra thread to run the asynchronous event loop
in. If I have
async_read events outstanding, wouldn't the above code cause my destructor
to block
until I've read another message (which may happen quite infrequently)?
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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