[asio-users] using a demuxer to poll
Brought to you by:
chris_kohlhoff
From: Arvid N. <c9...@cs...> - 2005-09-08 23:08:07
|
Hi. I want to use one of my demuxers to poll the messages received on any of its sockets. i.e. have the same semantics as calling select() with a timeout of 0. I'm doing it like this: asio::deadline_timer t(m_demuxer, milliseconds(0)); t.async_wait(bind(&asio::demuxer::interrupt, ref(m_demuxer))); m_demuxer.run(); m_demuxer.reset(); Does this guarantee that all pending socket events are handled before the timer event is handled and the demuxer is aborted? If, not is there a better way of achieving what I want? And another question, is there a reason why run doesn't call reset() before it quits? are there any operations in the demuxer that makes sense only when it's in the state of "just returned from run, but not reset"? or is the reset() operation expensive so one may want to skip it if run() is not to be called again? thanks -- Arvid Norberg |