Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio::Async_read_some - bytes_transferred=0!
From: Lloyd (lloyd_at_[hidden])
Date: 2010-06-28 08:52:01


>
> Maybe the thread that calls async_read exits before the relevant
> completion handler is invoked?
>
>
> By the way, using threads in the way you described in asio-based
> program is usually a bad idea. The whole point of using async i/o is
> to avoid such an "explicit" multithreading -- usually one spawns
> multiple threads to scale for multiple CPUs only.
> http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/examples.html#boost_asio.examples.http_server_3
> http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/examples.html#boost_asio.examples.http_server_2

Yes, you are right, the thread is exiting before the async_read_some.

I would like to let you know why I am using threads. This is a server
application. The client can give any command, and the server will execute
it. Some commands may take much longer time. In this kind of situations, the
client may want to STOP the execution of that long job. With the help of
threading I am able to do this with the help "Interruption points and
interrupts". The server will receive a "STOP command with the thread ID"
from the client, So the server can interrupt the thread and stop the job.

Is there a better way to implement this? I would be very happy to know
that, than using this dirty way I am using now...

Thanks a lot,
  Lloyd

______________________________________
Scanned and protected by Email scanner


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