Need explanation for this boost::asio timer example

Posted by ApplePieIsGood on Stack Overflow See other posts from Stack Overflow or by ApplePieIsGood
Published on 2010-03-20T02:38:33Z Indexed on 2010/03/20 2:41 UTC
Read the original article Hit count: 1015

Filed under:
|
|
|

There is a line in the 3rd tutorial on Boost asio that shows how to renew a timer and yet prevent there from being drift. The line is the following:

 t->expires_at(t->expires_at() + boost::posix_time::seconds(1));

Maybe it's me but I wasn't able to find documentation on the 2nd usage of expires_at(), with no parameters. expires_at(x) sets the new expiration, cancelling any pending completion handlers. So presumably expires_at() does what, return time of the last expiry? So by adding one second, if there should be some number of ms, say n ms, then it will in essence be "subtracted" from the next expiry since the time is being accounted for? What happens then if the time it takes to perform this handler is greater than 1 second in this example? Does it fire immediately?

© Stack Overflow or respective owner

Related posts about boost

Related posts about asio