1

I have to use timer in C++ to avoid using sleep() function. I have to do something at specified interval. I don't want to use WinApi timer class, because I want it work on both Linux and Windows.

Does C++ have built-in timer classes?

Mat
  • 202,337
  • 40
  • 393
  • 406
Over Killer
  • 507
  • 9
  • 24
  • 1
    You might use the periodic function reviewed here: http://codereview.stackexchange.com/questions/47347/follow-up-timer-utilizing-stdfuture –  May 01 '14 at 18:05
  • Look at headers ``, `` and ``. – Deduplicator May 01 '14 at 18:17
  • 1
    Are you looking for "cross platform timer"? Try this: http://stackoverflow.com/questions/1487695/c-cross-platform-high-resolution-timer – Arun May 01 '14 at 18:20
  • Well, nowadays you could do exactly what you are currently doing in a portable and standard way: Open a thread for the timer with ``, and sleep it by some intervals with `` – Manu343726 May 01 '14 at 18:56
  • @Manu343726 I'm not sure just moving the sleep() call to a different thread counts as avoiding the use of sleep() ;) – Jeremy Friesner May 01 '14 at 21:11

0 Answers0