On Mon, Sep 30, 2013 at 12:03 AM, Gavin Lambert <gavinl@compacsort.com> wrote:
On 9/30/2013 5:41 PM, Quoth Bo Jensen:

I have build a job queue with a combination io_service,
io_service::work, packaged_task and a thread group. I am seeing randomly
either segfaults or strange asserts in pthread or even malloc, which
suggest to me memory is being corrupted somehow.
[...]

I can wait for a job to finish like this :

               boost::wait_for_any(io_future_.begin(),io_future_.end());

What are you doing once this has returned?

In particular note that if you want to "give up" on retrieving any further results then you must stop() the io_service and join_all() the thread group (in that order) before you allow the io_service or thread_group to be destroyed.  Their respective destructors do not do this for you.

(Also note that this will of course still complete however many tasks have already started to process, unless you have some other means of cancelling a task in progress, such as using interruption points.)



Thank you for the reply, much appreciated.

I use interruptions points. When I want to stop workers and end the program I call :

    io_work_.reset();

    io_threads_.interrupt_all();

    JoinAllWorkers();


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 ?

Also I don't call join on the thread group, but on each thread individually, which I assume must be OK (done in JoinAllWorker()). 
 
 
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users