Boost logo

Boost Users :

From: dhruva (dhruvakm_at_[hidden])
Date: 2008-06-17 08:39:29


Hi,

On Tue, Jun 17, 2008 at 2:43 PM, Matthias Vallentin
<vallentin_at_[hidden]> wrote:
> corresponding thread. How can deal with blocking functions, such as a
> calls to accept() or when a thread is waiting on a condition variable

FWIK, there is no way to get out of blocking calls elegantly. The way
to go about it is to use non-blocking calls. Wait for multiple objects
(on windows I have used this) where one of the object is an event. On
an interrupt, you set the event and the wait will return.
For 'select', SAMBA has a neat trick. They create a pipe, the select
call also listens on one end of this pipe. On a signal, the signal
handler writes a char to the pipe which makes the call to select
return.
For non-blocking accept, you could check the SAMBA implementation of
socketpair. In a single thread, they create a socket, bind, accept,
connect and return the pair of connected sockets.

-dhruva

-- 
Contents reflect my personal views only!

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