|
Boost Users : |
Subject: Re: [Boost-users] Valgrind errors with ASIO
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2013-09-30 02:04:33
On 9/30/2013 6:21 PM, Quoth Bo Jensen:
> I see I have no io_service::stop(), but I read in a stack exchange reply
> that was not needed in this case, is that true ?
Mostly. If you don't stop() the io_service then it will still waste
some time entering each posted-but-not-yet-run job and running up until
the first interruption point (assuming that the interruption point will
still be "live" after the interruption exception has been thrown once,
which I'm not entirely sure about -- I haven't really played with
interruption points too much myself).
If your number of jobs is less than or equal to your number of worker
threads then this will be invisible except in a rare race if the job
completes very quickly. Even with a larger number of jobs it might be
hard to spot if some of their work is asynchronous itself, thereby
allowing all of the original jobs to get run early on.
Either way though as long as you join all the worker threads before you
allow the service to be destroyed then it ought to be safe -- if you hit
the above case then it'll just take longer to join than you might be
expecting.
> Also I don't call join on the thread group, but on each thread
> individually, which I assume must be OK (done in JoinAllWorker()).
The thread_group::join_all() is just an individual thread join in a
loop, so it should be fine as long as you're doing an unconditional join
and not a timed_join.
Otherwise I can't think of anything else helpful, sorry! :(
You could try asking on the asio-specific mailing list. They're likely
going to ask you to try to make a smaller test-case that you can share
in full though.
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