9 Sep
2008
9 Sep
'08
9:10 p.m.
void print1() { if (count_ < 100) { timer1_.expires_at(timer1_.expires_at() + boost::posix_time::microseconds(10)); timer1_.async_wait(boost::bind(&printer::print1, this)); std::cout << "Timer 1: " << count_ << "\n"; ++count_;
}
Over a period of time I think it will probably cause some slippage.
This is because you always take a new "reference time". I guess that if you store the initial reference-point (when starting the timer for the 1st time) and then always add to *it* a time_duration*iterationNumber, then the slippage wouldn't accumulate.