Re: [Boost-users] Thread Interruption Best Practice

if I understand your problem you want the thread blocking in select to return?
Correct. I need this call to return when: 1) I've got some data waiting to be read. 2) The application is terminating and I want to stop my RX communications thread. The first one is straightforward. I'll investigate the use of pipes as a secondary option. As for 2), from other suggestions, I've gone back to the ASIO library. I read about slushies and brain-freeze, and thought it might be the way to go. However, I think I've managed to fall victim to brainfreeze myself.
From the ASIO example at: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/echo/async_...
This is an asynchronous server similar to what I'm trying to do here. I've got a couple of questions on this, 1) When the server object is created, the call to socket.async_read_from() is made immediately. If there is no data waiting, to be read, this call returns immediately, right? 2) When data does arrive, the handler 'handle_receive_from()' is called. Regardless of whether some bytes are read or not, we eventually call socket.async_read_from() again. This is probably quite fundamental to what I'm misunderstanding, but doesn't this mean I'll be effectively calling socket.async_read_from() from within the handler of a call to socket.async_read_from()? Will I be recursing indefinitely until the application terminates? That doesn't sound right, so I must be missing something very obvious here. Hmmm. Biblical-style ray-of-light guidance appreciated!
participants (1)
-
Dom Driver