[Asio] Erratic results with io_service + deadline_timer
Today I tried using Boost.Asio to make a function get called at a particular
time of day. My work included some tests, which usually passed but
sometimes failed. I've boiled it down below. I'm using gcc 4.0.3 and Boost
1.35 on Linux 2.6.22 (Ubuntu Dapper 32-bit i686, quad-core CPU). I compiled
the following code with g++ -lboost_thread -lboost_date_time -lboost_system
:
#include
for(;;) { g_svc.run(); }
You don't have to call run() in a loop. Instead, you have to give io_service some work *before* you call run() - it will exit when there's no more work to do. Anyway, if for some reason you have to call run() again, you're expected to call reset() prior to run(). Please, refer to the manual: http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/reference/io_servic...
participants (2)
-
Igor R
-
John Zwinck