From: JH (jupiter.hce_at_[hidden])
Date: 2019-08-26 14:05:27
On 8/26/19, Gavin Lambert via Boost <boost_at_[hidden]> wrote:
> On 26/08/2019 19:17, JH wrote:
>> My problem is I have wired behavior for expiry at absolute time, I
>> have used deadline_timer for relative time for long time which works
>> well, but I could not get the absolute time work, here is what I set
>> up the timer to expire at 1minute 0 seconds:
>> boost::posix_time::ptime posixTime(clockNow,
>> boost::posix_time::hours(utcTime.time_of_day().hours()) +
>> boost::posix_time::minutes(utcTime.time_of_day().minutes() + 1));
>> async_wait(boost::bind(&ClockTimer::Handler, this,
>> So the expiry time is 2019-Aug-26 07:09:00, but when the timer
>> expired, it called callback function 8 times consecutively, what could
>> I be wrong here?
> Are you calling async_wait more than once?
Nope, a function wrapped the pair of expires_at and async_wait for
absolute time or expires_from_now async_wait for relative time.
> Each call to async_wait will queue up one callback when the timer
> expires. They will "stack up" if you call it more than once.
> Calling expires_at will cancel all previous async_wait calls (except in
> some borderline cases when the timer was concurrently expiring), but the
> callback function will still be called (with the operation_aborted code).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk