Jump to content
  • Advertisement
Sign in to follow this  
laztrezort

Design suggestions for scheduler

This topic is 3415 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

Hello all! I am in the process of re-designing some libraries I wrote a while back as a pet-project. I want to update the mostly "C-style" code to safer, more extensible "C++ style" code. Anyway, now I'm trying to tackle a basic scheduler module. The idea is simple: the scheduler (lets call it class Scheduler) iterates over a list of Entity <smart>pointers, calling Entity->DoSomething() each time. DoSomething() returns a value (a "cost") representing how long the action took (conceptually in game time, not actual time). Entities such as characters, an input handler, a game clock, spell timers, etc. can be added to Schedule, and the game loop basically becomes: Scheduler.AddEntities(); do { Scheduler.Run(); } while !GameState.quit The whole purpose of this was written for a turn-based game, although I don't see why it couldn't be used in a real-time scenario. The possible problem as I see it, is that this is intrusive. That is, any object that wants to be part of the scheduler must inherit Entity interface. Basically, I don't want to lock myself into a design consideration that I might regret later. One alternative I considered was to just pass a member function pointer to the Scheduler, but that seems dangerous to me: if the Entity has been destructed without removing it from Scheduler, bad things would undoubtedly ensue. So: anyone have any other/better suggestions on doing something like this? I feel like I may be missing something fundamental here, due to my inexperience. Of course, using Entity inheritance may be the perfect solution, and maybe I just need some reassurance [embarrass] Thanks for any advice (and sorry if I was too long-winded!)

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!