Hi,<br><br><div class="gmail_quote">2009/9/24 Daniele Barzotti <span dir="ltr"><<a href="mailto:daniele.barzotti@eurocomtel.com">daniele.barzotti@eurocomtel.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> In my library I have this code (yet used in another project) where pwork<br> is assigned to a shared_ptr:<br> <br> --------------------------------------------------------------<br> typedef boost::shared_ptr<boost::asio::io_service::work> io_work_ptr;<br> <br> // Main io_service<br> static boost::asio::io_service � � � � �io_service;<br> static boost::scoped_ptr<boost::thread> io_service_thread;<br> static boost::asio::io_service::work* � p_work;<br> static bool � � � � � � � � � � � � � � thread_started;<br> <br> <br> bool CreateMainThread()<br> {<br> �if (!thread_started) {<br> � �try {<br> � � �// create the work object on the heap<br> � � �p_work = new boost::asio::io_service::work(io_service);<br> <br> � � �// run the IO service as a separate thread:<br> � � �io_service_thread.reset (<br> � � � new boost::thread (<br> � � � � boost::bind (<br> � � � � � &boost::asio::io_service::run, &io_service<br> � � � � )<br> � � � )<br> � � �);<br> <br> � � �thread_started = !thread_started;<br> � � �return true;<br> <br> � �} catch (boost::thread_resource_error e) {<br> � � �// Failed to create the new thread<br> � � �return false;<br> � �}<br> �}<br> }<br> --------------------------------------------------------------<br> <br> WaveStream::WaveStream() : rx_timer_(io_service)<br> {<br> };<br> <br> WaveStream::Test()<br> {<br> �//Start a new timer or renew it<br> �rx_timer_.expires_from_now( boost::posix_time::milliseconds(500) );<br></blockquote><div>I'm thinking would that be correct if you call timer after async_wait() ?<br>�</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> �// We managed to cancel the timer. Start new asynchronous wait.<br></blockquote><div><br>have You tried restet io_service in this thread, before putting the query on the queue?<br>io_service.reset() <br>If thats correct from Your businesses logic.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> �rx_timer_.async_wait(<br> � �boost::bind(&WaveStream::handle_timeout, this, _1)<br> �);<br> }<br> <br> void WaveStream::handle_timeout(const boost::system::error_code& error)<br> {<br> �....<br> }<br> --------------------------------------------------------------<br> <br> The timer callback is never called.<br> Is there a way to know if the io_service is runing?<br> <br> Daniele.<br> <br> <br> _______________________________________________<br> Boost-users mailing list<br> <a href="mailto:Boost-users@lists.boost.org">Boost-users@lists.boost.org</a><br> <a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br></blockquote><div><br><br>cheers<br>P. <br></div></div><br>