Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

How to code optional callbacks at expiration of timer?

This topic is 1725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!