
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Sebastian Redl Sent: 07 April 2008 14:23 To: boost@lists.boost.org Subject: Re: [boost] Asynchronous Boost.Iostreams with Boost.Asio
Boris wrote:
On Mon, 07 Apr 2008 11:40:48 +0200, Sebastian Redl <sebastian.redl@getdesigned.at> wrote:
The only way to simulate asynchronous I/O using blocking calls is to use a separate thread for every I/O object.
This doesn't work either as you can't interrupt the blocking call if you want to close the stream.
You can kill the thread. Not exactly portable, and will probably leak resources, though.
Not a good plan. We have recently run into a problem where our application would not shut down because a library had used TerminateThread to (ahem) terminate a thread. The thread had been holding a Critical Section (Win32 within-process-only mutex), and when some other thread tried to acquire the critical section there was a rather long wait for the terminated thread to release it. It is extremely difficult to know what resources IOStreams will use internally, but protecting access via a critical section seems entirely plausible. -- Martin Bonner Senior Software Engineer/Team Leader PI SHURLOK LTD Telephone: +44 1223 441434 / 203894 (direct) Fax: +44 1223 203999 Email: martin.bonner@pi-shurlok.com www.pi-shurlok.com disclaimer