How to code optional callbacks at expiration of timer?

Started by
4 comments, last by MARS_999 10 years, 6 months ago
I can't find any examples of how to code or make a class that you can set a timer limit of some duration and then the function or object to be called or looped over "X" amount of times then quit... Any ideas or examples would be greatly appreciated!
Advertisement
What platform are you working on? There are dozens of ways to implement timers but which one suits you will depend on a lot of factors. More details would be nice.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

You can pass functions as parameters in C++. You can create some kind of callback functionality by using this feature.

I am aiming for cross platform, and C++. I would like to use some kind of template class so I can pass whatever... e.g. function or object to the timer call back. Are there any libs out there that do this already? Thanks!
There is either boost::function or in C++11 std::function. std::function is practically identical to boost::function, however boost::function is available on most compilers (everything remotely modern) even without C++11.

There is either boost::function or in C++11 std::function. std::function is practically identical to boost::function, however boost::function is available on most compilers (everything remotely modern) even without C++11.

Thank you I will look at this! Good to know!

This topic is closed to new replies.

Advertisement