Boost Users :
Subject: Re: [Boost-users] Asio::Async_read_some - bytes_transferred=0!
From: Igor R (boost.lists_at_[hidden])
Date: 2010-06-28 09:29:19
> Yes, you are right, the thread is exiting before the async_read_some.
You mean "before async_read_some completion"? At least on Windows,
this would cause the following behavior:
"Note All I/O initiated by a given thread is canceled when that
thread exits. For overlapped sockets, pending asynchronous operations
can fail if the thread is closed before the operations complete. "
> 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...
Well, you can launch threads for your tasks -- still processing all
the i/o in one thread (where you call io_service::run()):
// pseudo code
// gotCommand is always being called from within a single thread,
where io_service::run() is running
void gotCommand(Command cmd)
Task task = makeTask(cmd);
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