Jump to content

View more

Image of the Day

The beast has a mighty searchlight of evil! #screenshotsaturday https://t.co/bzKepOojDL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

How to code optional callbacks at expiration of timer?

4: Adsense

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   

1621
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!

#2 ApochPiQ   Moderators   

22567
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.
Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

#3 GuardianX   Members   

1586
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   

1621
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   Members   

8647
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   

1621
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.