|
Boost Users : |
Subject: Re: [Boost-users] [asio] sync receive_from with timeout
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2009-03-04 09:20:02
Hi Ovanes,
> > So each thread
> > calling that interruptable receive would have to have it's boost::thread
> > object to pass it to the function, right?
...
> Yes, you probably need to pass a thread reference to be interrupted after
> some timeout, otherwise that would not work.
Well, I just tried to work around that with io_services running thread pools and all but there's little hope as all things I could come up with that realize this would require the thread object. The only thing I could imagine would be an extra thread which could be created to execute the blocking IO starts, while the original thread goes into a sleep that can be interrupted by the new thread upon successfuly return of the blocking read.
like this (pseudo):
void readthread() {
// go into blocking read
sock.sync_receive_from(...);
}
original thread:
...
thread t1(readthread);
try {
boost::this_thread::sleep(timeout)
} catch (const boost::thread_interrupted &e) {
}
..but that would of course mean a new thread each time and I don't think it'll work. Looks like I'm gonna have to find another way.
Cheers...
Stephan
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