c++ - Interrupt boost::asio synchronous read? -
I am using asio synchronous sockets to read data from TCP on background thread, explained in a "server" class has gone.
However, I want to get the thread out when the destroyer of this class is called. The problem is that the call blocks any read function, so the thread can not be easily exhausted. Win32 has an API for this: WaitForMultipleObjects
what I really want
How do I get the same effect with promotion?
In our application, we set the "Termination" status, and then on the port a self-connection Use the thread on which the thread is listening, it arises, notes the ending condition and ends.
You can also see the Improved Implementation - if they are just reading a simple on the socket (i.e., by any means WaitforMultipleObjects are not using their own internal use) you might conclude that It is possible that there is nothing to just and completely unblock the thread if they are waiting on multiple objects (or perfection port), then you can see that the ability to wake up the blocked thread The side of town.
Finally, you can kill the thread - but you have to go out of promoting to do so, and understand the consequences, such as dangling or leaking resources if you are shutting down, So this is not a matter of concern, it depends on what the thread was doing.
Comments
Post a Comment