Boost logo

Boost Users :

Subject: [Boost-users] asio: transporting exceptions across threads
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-07-21 14:00:37


Suppose I have some io_service object in which I call run() from
thread A. Thread A is the main controller of the i/o operations and
does things like issuing reads and, upon completion, issuing writes
for those reads. The writing service might wish to spawn off some
child services that runs in thread B. So when thread A says
writer.async_write_data() all it really does is call
child_writer_service.post() with the data.

Supposing an exception occurs in thread B, what is the best way to
have this terminate the entire asio pipeline and propagate the
exception all the way up to outside of thread A's call to
io_service::run()?

I've looked at the sample code on the boost::exception tutorial but
I'm unable to apply this to the situation in asio, either due to
differences in the threading model or due to my own misunderstandings.

Thanks


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