Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6835 closed Bugs (invalid)

Timer and Sleep issues with system clock

Reported by: Luc Moreault <lmoreault@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

Hi,

I think there is an isue currently with some of the classes that use time sensitive code.

After a quick look, I found that boost::deadline_timer and this_thread::sleep() were sensitive to system clock change.

Even if using durations (instead of relative times) setting the system clock back affects those timers.

Do you know what might be the cause of such behavior (eventhough duration is used)?

Thanks

Change History (6)

comment:1 by Luc Moreault <lmoreault@…>, 10 years ago

Hi,

Anybody witnessed the same issue or tried to replicate it?

This can cause serious issues in some situations where the clock is set when the code is running.

Thanks

comment:2 by chris_kohlhoff, 10 years ago

Resolution: invalid
Status: newclosed

The asio::deadline_timer typedef uses the UTC clock, as documented here.

If you don't want to be sensitive to UTC clock changes then use the new asio::steady_timer typedef, or write your own custom time traits to use an alternative clock as shown in this example.

comment:3 by Luc Moreault <lmoreault@…>, 10 years ago

Hi chris,

Thanks for the steady_timer pointer. Do you have a similar suggestion for other timing related calls? (this_thread::sleep)

Regards, Luc

in reply to:  3 comment:4 by chris_kohlhoff, 10 years ago

You could use steady_timer's synchronous wait() function.

comment:5 by anonymous, 10 years ago

Was that also changed in condition_variable (timed_wait)?

Thanks, Luc

comment:6 by chris_kohlhoff, 10 years ago

Not my area, sorry.

Note: See TracTickets for help on using tickets.