Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to code optional callbacks at expiration of timer?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 MARS_999   Members   -  Reputation: 1297

Like
0Likes
Like

Posted 28 September 2013 - 11:59 PM

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!

Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 16415

Like
0Likes
Like

Posted 29 September 2013 - 12:10 AM

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.

#3 GuardianX   Crossbones+   -  Reputation: 1527

Like
1Likes
Like

Posted 29 September 2013 - 01:18 AM

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



#4 MARS_999   Members   -  Reputation: 1297

Like
0Likes
Like

Posted 29 September 2013 - 01:57 AM

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!

#5 BitMaster   Crossbones+   -  Reputation: 4442

Like
1Likes
Like

Posted 30 September 2013 - 07:56 AM

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.

#6 MARS_999   Members   -  Reputation: 1297

Like
0Likes
Like

Posted 30 September 2013 - 12:01 PM

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!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS